Freigeben über


SoapHttpClientProtocol.EndInvoke-Methode

Beendet den asynchronen Aufruf einer XML-Webdienstmethode unter Verwendung von SOAP.

Namespace: System.Web.Services.Protocols
Assembly: System.Web.Services (in system.web.services.dll)

Syntax

'Declaration
Protected Function EndInvoke ( _
    asyncResult As IAsyncResult _
) As Object()
'Usage
Dim asyncResult As IAsyncResult
Dim returnValue As Object()

returnValue = Me.EndInvoke(asyncResult)
protected Object[] EndInvoke (
    IAsyncResult asyncResult
)
protected:
array<Object^>^ EndInvoke (
    IAsyncResult^ asyncResult
)
protected Object[] EndInvoke (
    IAsyncResult asyncResult
)
protected function EndInvoke (
    asyncResult : IAsyncResult
) : Object[]

Parameter

Rückgabewert

Ein Array von Objekten mit dem Rückgabewert und allen durch Verweis übergebenen Parametern oder out-Parametern der abgeleiteten Klassenmethode.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

asyncResult ist nicht der Rückgabewert der BeginInvoke-Methode.

SoapException

Die Anforderung hat den Servercomputer erreicht, wurde jedoch nicht erfolgreich verarbeitet.

Hinweise

Sie rufen die EndInvoke-Methode i. d. R. nur dann direkt auf, wenn Sie eine eigene Proxyklasse für einen XML-Webdienst erstellen.

Eine durch das WSDL-Tool (Wsdl.exe) für einen XML-Webdienst generierte Proxyklasse macht die XML-Webdienstmethoden als Namen aus der Proxyklasse zum synchronen Aufrufen der XML-Webdienstmethoden verfügbar. Zum asynchronen Aufrufen der XML-Webdienstmethoden werden der Proxyklasse für jede XML-Webdienstmethode zwei zusätzliche Proxyklassen hinzugefügt: eine Proxyklasse, bei der das Begin-Präfix dem Namen der XML-Webdienstmethode hinzugefügt wird, sowie eine mit hinzugefügtem End-Präfix.

Die Proxyklasse ruft zum Beenden eines asynchronen Aufrufs an die XML-Webdienstmethode die EndInvoke-Methode auf. Wenn ein XML-Webdienst beispielsweise die XML-Webdienstmethode Add verfügbar macht, enthält die Proxyklasse zum Beenden des asynchronen Aufrufs einer XML-Webdienstmethode die Methode EndAdd. Innerhalb von Code für EndAdd wird die EndInvoke-Methode aufgerufen, und die Ergebnisse werden in den für Add erwarteten Rückgabetyp positioniert.

Beispiel

Im folgenden Codebeispiel wird eine von Wsdl.exe generierte Proxyklasse für den Math-XML-Webdienst veranschaulicht. Innerhalb der EndAdd-Methode der Proxyklasse schließt die EndInvoke-Methode einen asynchronen Aufruf an die Add-XML-Webdienstmethode ab.

Option Strict On
Option Explicit On

Imports System
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

Namespace MyMath
    
    <System.Web.Services.WebServiceBindingAttribute(Name:="MyMathSoap", [Namespace]:="https://www.contoso.com/")>  _
    Public Class MyMath
        Inherits System.Web.Services.Protocols.SoapHttpClientProtocol
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Sub New()
            MyBase.New
            Me.Url = "https://www.contoso.com/math.asmx"
        End Sub
        
        <System.Diagnostics.DebuggerStepThroughAttribute(),  _
         System.Web.Services.Protocols.SoapDocumentMethodAttribute("https://www.contoso.com/Add", RequestNamespace:="https://www.contoso.com/", ResponseNamespace:="https://www.contoso.com/", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>  _
        Public Function Add(ByVal num1 As Integer, ByVal num2 As Integer) As Integer
            Dim results() As Object = Me.Invoke("Add", New Object() {num1, num2})
            Return CType(results(0),Integer)
        End Function
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Function BeginAdd(ByVal num1 As Integer, ByVal num2 As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState As Object) As System.IAsyncResult
            Return Me.BeginInvoke("Add", New Object() {num1, num2}, callback, asyncState)
        End Function
        
        <System.Diagnostics.DebuggerStepThroughAttribute()>  _
        Public Function EndAdd(ByVal asyncResult As System.IAsyncResult) As Integer
            Dim results() As Object = Me.EndInvoke(asyncResult)
            Return CType(results(0),Integer)
        End Function
    End Class
End Namespace
namespace MyMath {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.Web.Services;
    
    
    [System.Web.Services.WebServiceBindingAttribute(Name="MyMathSoap", Namespace="https://www.contoso.com/")]
    public class MyMath : System.Web.Services.Protocols.SoapHttpClientProtocol {
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public MyMath() {
            this.Url = "https://www.contoso.com/math.asmx";
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("https://www.contoso.com/Add", RequestNamespace="https://www.contoso.com/", ResponseNamespace="https://www.contoso.com/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public int Add(int num1, int num2) {
            object[] results = this.Invoke("Add", new object[] {num1,
                        num2});
            return ((int)(results[0]));
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public System.IAsyncResult BeginAdd(int num1, int num2, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("Add", new object[] {num1,
                        num2}, callback, asyncState);
        }
        
        [System.Diagnostics.DebuggerStepThroughAttribute()]
        public int EndAdd(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((int)(results[0]));
        }
    }
}
#using <System.Web.Services.dll>
#using <System.Xml.dll>
#using <System.dll>

using namespace System::Diagnostics;
using namespace System::Xml::Serialization;
using namespace System;
using namespace System::Web::Services::Protocols;
using namespace System::Web::Services;

namespace MyMath
{

   [System::Web::Services::WebServiceBindingAttribute(Name="MyMathSoap",Namespace="https://www.contoso.com/")]
   public ref class MyMath: public System::Web::Services::Protocols::SoapHttpClientProtocol
   {
   public:

      [System::Diagnostics::DebuggerStepThroughAttribute]
      MyMath()
      {
         this->Url = "https://www.contoso.com/math.asmx";
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      [System::Web::Services::Protocols::SoapDocumentMethodAttribute("https://www.contoso.com/Add",RequestNamespace="https://www.contoso.com/",ResponseNamespace="https://www.contoso.com/",Use=System::Web::Services::Description::SoapBindingUse::Literal,ParameterStyle=System::Web::Services::Protocols::SoapParameterStyle::Wrapped)]
      int Add( int num1, int num2 )
      {
         array<Object^>^temp0 = {num1,num2};
         array<Object^>^results = this->Invoke( "Add", temp0 );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      System::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState )
      {
         array<Object^>^temp1 = {num1,num2};
         return this->BeginInvoke( "Add", temp1, callback, asyncState );
      }


      [System::Diagnostics::DebuggerStepThroughAttribute]
      int EndAdd( System::IAsyncResult^ asyncResult )
      {
         array<Object^>^results = this->EndInvoke( asyncResult );
         return  *dynamic_cast<int^>(results[ 0 ]);
      }

   };

}
package MyMath; 

import System.Diagnostics.*;
import System.Xml.Serialization.*;
import System.*;
import System.Web.Services.Protocols.*;
import System.Web.Services.*;

/** @attribute System.Web.Services.WebServiceBindingAttribute(
     Name = "MyMathSoap", Namespace = "https://www.contoso.com/")
 */

public class MyMath extends System.Web.Services.Protocols.SoapHttpClientProtocol
{
    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public MyMath()
    {
        this.set_Url("https://www.contoso.com/math.asmx");
    } //MyMath

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    /** @attribute System.Web.Services.Protocols.SoapDocumentMethodAttribute(
        "https://www.contoso.com/Add", RequestNamespace = 
        "https://www.contoso.com/", ResponseNamespace = 
        "https://www.contoso.com/", Use = 
        System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle 
        = System.Web.Services.Protocols.SoapParameterStyle.Wrapped)
     */

    public int Add(int num1, int num2)
    {
        Object results[] = this.Invoke("Add", new Object[] { 
            (Int32)num1, (Int32)num2 });
        return (int)((Int32)results.get_Item(0));
    } //Add

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public System.IAsyncResult BeginAdd(int num1, int num2, 
        System.AsyncCallback callback, Object asyncState)
    {
        return this.BeginInvoke("Add", new Object[] { 
            (Int32)num1, (Int32)num2 }, callback, asyncState);
    } //BeginAdd

    /** @attribute System.Diagnostics.DebuggerStepThroughAttribute()
     */

    public int EndAdd(System.IAsyncResult asyncResult)
    {
        Object results[] = this.EndInvoke(asyncResult);
        return (int)((Int32)results.get_Item(0));
    } //EndAdd
} //MyMath

Im folgenden Codebeispiel wird der Math-XML-Webdienst veranschaulicht, aus dem die vorherige Proxyklasse erstellt wurde.

<%@ WebService Language="VB" Class="MyMath"%>
Imports System.Web.Services
Imports System

<WebService(Namespace:="https://www.contoso.com/")> _
Public Class MyMath
    <WebMethod()> _
    Public Function Add(num1 As Integer, num2 As Integer) As Integer
        Return num1 + num2
    End Function 'Add
End Class 'Math
<%@ WebService Language="C#" Class="MyMath"%>
 using System.Web.Services;
 using System;
 
 [WebService(Namespace="https://www.contoso.com/")] 
 public class MyMath {
      [ WebMethod ]
      public int Add(int num1, int num2) {
          return num1+num2;
          }
 }
<%@ WebService Language="VJ#" Class="MyMath"%>
import System.Web.Services .* ;
import System .* ;


/** @attribute WebService(Namespace = "https://www.contoso.com/")
* */
public class MyMath
{
   /** @attribute WebMethod()
   * */
   public int Add(int num1, int num2) 
   {
      return num1 + num2 ;
   } 
} 

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

SoapHttpClientProtocol-Klasse
SoapHttpClientProtocol-Member
System.Web.Services.Protocols-Namespace
IAsyncResult
BeginInvoke
WebClientProtocol