ReportingService2005.CancelBatch 方法

定义

取消通过调用 CreateBatch() 方法启动的批处理。

public:
 void CancelBatch();
public void CancelBatch ();
member this.CancelBatch : unit -> unit
Public Sub CancelBatch ()

示例

若要编译此代码示例,必须引用Reporting Services Web 服务描述语言 (WSDL) 并导入某些命名空间。 有关详细信息,请参阅 编译和运行代码示例。 下面的代码示例取消批处理,尝试执行该批,并显示错误详细信息:

Imports System  
Imports System.Web.Services.Protocols  

Class Sample  
   Public Shared Sub Main()  
      Dim rs As New ReportingService2005()  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials  

      Dim bh As New BatchHeader()  
      bh.BatchID = rs.CreateBatch()  
      rs.BatchHeaderValue = bh  
      rs.CreateFolder("New Folder1", "/", Nothing)  
      rs.CreateFolder("New Folder2", "/", Nothing)  
      rs.CreateFolder("New Folder3", "/", Nothing)  

      Console.WriteLine("Cancelling current batch operation.")  

      ' Cancel the current batch.  
      Try  
         rs.CancelBatch()  

      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
      End Try  

      Try  
         ' Generates an error because the batch has already been cancelled.  
         rs.ExecuteBatch()  
         Console.WriteLine("The batch executed successfully.")  

      Catch e As SoapException  
         Console.WriteLine(e.Detail.InnerXml.ToString())  
         Console.WriteLine("The batch was not executed.")  

      Finally  
         rs.BatchHeaderValue = Nothing  
      End Try  
   End Sub 'Main  
End Class 'Sample  
using System;  
using System.Web.Services.Protocols;  

class Sample  
{  
   public static void Main()  
   {  
      ReportingService rs = new ReportingService2005();  
      rs.Credentials = System.Net.CredentialCache.DefaultCredentials;  

      BatchHeader bh = new BatchHeader();  
      bh.BatchID = rs.CreateBatch();  
      rs.BatchHeaderValue = bh;  
      rs.CreateFolder("New Folder1", "/", null);  
      rs.CreateFolder("New Folder2", "/", null);  
      rs.CreateFolder("New Folder3", "/", null);  

      Console.WriteLine("Cancelling current batch operation.");  

      // Cancel the current batch.  
      try  
      {  
         rs.CancelBatch();  
      }  

      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());  
      }  

      try  
      {  
         // Generates an error because the batch has already been cancelled.  
         rs.ExecuteBatch();  
         Console.WriteLine("The batch executed successfully.");  
      }  

      catch (SoapException e)  
      {  
         Console.WriteLine(e.Detail.InnerXml.ToString());  
         Console.WriteLine("The batch was not executed.");  
      }  

      finally  
      {  
         rs.BatchHeaderValue = null;  
      }  
   }  
}  

注解

下表显示了有关此操作的标头和权限信息。

SOAP 标头 (In) BatchHeaderValue

(Out) ServerInfoHeaderValue
所需的权限 用户必须是数据库管理员或配置为无人参与执行帐户的用户。 有关详细信息,请参阅 执行帐户 (SSRS 本机模式)

在调用 方法之前,必须指定要取消的批的 CancelBatch ID。 为此, BatchHeaderValue 可以将报表服务器 Web 服务的 属性设置为与创建批处理时生成的批 ID 相等的值。

CancelBatch调用 方法时,无法再执行与批 ID 关联的任何方法调用。 任何尝试使用已取消的批 ID 执行批处理都会导致 SOAP 异常,错误代码 rsBatchNotFound为 。

适用于

另请参阅