共用方式為


批次方法

在 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 = "http://<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 = "http://<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;
    }
}