次の方法で共有


CancelBatch メソッド

CreateBatch メソッドの呼び出しによって開始されたバッチをキャンセルします。

名前空間:  ReportService2005
アセンブリ:  ReportService2005 (ReportService2005.dll)

構文

'宣言
<SoapHeaderAttribute("BatchHeaderValue")> _
<SoapHeaderAttribute("ServerInfoHeaderValue", Direction := SoapHeaderDirection.Out)> _
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelBatch", RequestNamespace := "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",  _
    ResponseNamespace := "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Sub CancelBatch
'使用
Dim instance As ReportingService2005

instance.CancelBatch()
[SoapHeaderAttribute("BatchHeaderValue")]
[SoapHeaderAttribute("ServerInfoHeaderValue", Direction = SoapHeaderDirection.Out)]
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelBatch", RequestNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public void CancelBatch()
[SoapHeaderAttribute(L"BatchHeaderValue")]
[SoapHeaderAttribute(L"ServerInfoHeaderValue", Direction = SoapHeaderDirection::Out)]
[SoapDocumentMethodAttribute(L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelBatch", RequestNamespace = L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = L"https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse::Literal, ParameterStyle = SoapParameterStyle::Wrapped)]
public:
void CancelBatch()
[<SoapHeaderAttribute("BatchHeaderValue")>]
[<SoapHeaderAttribute("ServerInfoHeaderValue", Direction = SoapHeaderDirection.Out)>]
[<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices/CancelBatch", RequestNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    ResponseNamespace = "https://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)>]
member CancelBatch : unit -> unit 
public function CancelBatch()

説明

キャンセルするバッチの ID は、CancelBatch メソッドを呼び出す前に指定する必要があります。この指定は、レポート サーバー Web サービスの BatchHeaderValue プロパティに、バッチの作成時に生成されたバッチ ID と同じ値を設定することにより、実行できます。

CancelBatch メソッドが呼び出されると、そのバッチ ID に関連付けられているすべてのメソッドの呼び出しの実行が停止されます。キャンセルされたバッチ ID を使ってバッチを実行しようとすると、SOAP 例外がエラー コード rsBatchNotFound で発生します。

使用例

このコード例をコンパイルするには、Reporting Services の Web サービス記述言語 (WSDL) を参照し、特定の名前空間をインポートする必要があります。詳細については、「Compiling and Running Code Examples」を参照してください。次のコード例では、バッチをキャンセルした後、そのバッチの実行を試行し、エラーの詳細を表示します。

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;
      }
   }
}