Batch 方法
在 Reporting Services 中使用 SOAP 標頭,可讓您在單一作業中包含多個 Web 服務方法。 方法會在單一資料庫交易的範圍內執行,依呼叫的順序執行。
交易回復是使用多個方法批次作業的其中一個優點。 如果在批次執行時在任何方法呼叫上發生錯誤,報表伺服器會停止執行批次,並回復任何先前的作業。 當方法呼叫相依於該批次中其他方法呼叫的成功完成時,此動作很有用。
Web 服務不提供多個方法批次作業的鎖定語意。 在將訊息傳送至伺服器並 Execute
呼叫 命令之前,報表伺服器資料庫中的數據列不會鎖定以進行更新。
沒有任何並行控件存在,可保證自上次讀取數據后,沒有人變更資料庫。 如果兩個用戶端修改相同的專案,如果參數仍然有效,則上次更新會成功(例如,專案的名稱相同)。
下列範例會呼叫 CreateFolder 方法三次,並將以單一批次執行這些呼叫。 如果呼叫 CreateFolder 失敗,則會取消整個批次。
Imports System
Imports System.Web.Services.Protocols
Imports myNamespace.MyReferenceName
Class Sample
Sub Main(args() As String)
Dim rs As New ReportingService2005()
rs.Credentials = System.Net.CredentialCache.DefaultCredentials
' Set the base Web service URL of the source server
rs.Url = "https://<Server Name>/reportserver/ReportService2005.asmx"
Dim bh As New BatchHeader()
bh.BatchId = service.CreateBatch()
rs.BatchHeaderValue = bh
rs.CreateFolder("New Folder1", "/", Nothing)
rs.CreateFolder("New Folder2", "/", Nothing)
rs.CreateFolder("New Folder3", "/", Nothing)
Console.WriteLine("Creating folders...")
rs.BatchHeaderValue = bh
rs.ExecuteBatch()
Console.WriteLine("Folders created successfully.")
rs.BatchHeaderValue = Nothing
End Sub
End Class
using System;
using System.Web.Services.Protocols;
using myNamespace.MyReferenceName;
class Sample
{
static void Main(string[] args)
{
ReportingService2005 rs = new ReportingService2005();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Set the base Web service URL of the source server
rs.Url = "https://<Server Name>/reportserver/ReportService2005.asmx"
BatchHeader bh = new BatchHeader();
bh1.BatchID = service.CreateBatch();
rs.BatchHeaderValue = bh;
rs.CreateFolder("New Folder1", "/", null);
rs.CreateFolder("New Folder2", "/", null);
rs.CreateFolder("New Folder3", "/", null);
Console.WriteLine("Creating folders...");
rs.BatchHeaderValue = bh1;
rs.ExecuteBatch();
Console.WriteLine("Folders created successfully.");
rs.BatchHeaderValue = null;
}
}