HttpSimpleClientProtocol.EndInvoke Method (IAsyncResult)

 

Completes asynchronous invocation of an XML Web service method using HTTP.

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

Protected Function EndInvoke (
	asyncResult As IAsyncResult
) As Object

Parameters

asyncResult
Type: System.IAsyncResult

The IAsyncResult returned from the BeginInvoke method.

Return Value

Type: System.Object

An array of objects containing the return value and any by reference or out parameters for the XML Web service method.

Exception Condition
ArgumentException

asyncResult is not the return value from the BeginInvoke method.

The following code example is an ASP.NET Web Form, which calls an XML Web service named Math. Within the EnterBtn_Click function, the Web Form starts and completes an asynchronous invocation of the Add XML Web service method.

<%@ Page Language="VB" %>
<html>
    <script language="VB" runat="server">
    Sub EnterBtn_Click(Src As Object, E As EventArgs)
        Dim math As New MyMath.Math()

        ' Call to Add XML Web service method asynchronously.
        Dim result As IAsyncResult = math.BeginAdd(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text), Nothing, Nothing)

        ' Wait for the asynchronous call to complete.
        result.AsyncWaitHandle.WaitOne()

        ' Complete the asynchronous call to the Add XML Web service method.
        Dim iTotal As Integer = math.EndAdd(result)

        Total.Text = "Total: " & iTotal.ToString()
    End Sub 'EnterBtn_Click

  </script>

    <body>
       <form action="MathClient.aspx" runat=server>

          Enter the two numbers you want to add and then press the Total button.
          <p>
          Number 1: <asp:textbox id="Num1" runat=server/>  +
          Number 2: <asp:textbox id="Num2" runat=server/> =
          <asp:button text="Total" Onclick="EnterBtn_Click" runat=server/>
          <p>
          <asp:label id="Total"  runat=server/>

       </form>
    </body>
 </html>

The following code example is a proxy class generated by the Web Services Description Language tool (Wsdl.exe) for the Math XML Web service below. Within the EndAdd method of the proxy class, the EndInvoke method starts an asynchronous invocation of the Add XML Web service method.

Namespace MyMath
    <XmlRootAttribute("int", Namespace := "http://MyMath/", IsNullable := False)> _
    Public Class Math
        Inherits HttpGetClientProtocol

        Public Sub New()
            Me.Url = "http://www.contoso.com/math.asmx"
        End Sub 'NewNew

        <HttpMethodAttribute(GetType(XmlReturnReader), GetType(UrlParameterWriter))> _
        Public Function Add(num1 As String, num2 As String) As Integer
            Return CInt(Me.Invoke("Add", Me.Url + "/Add", New Object() {num1, num2}))
        End Function 'Add


        Public Function BeginAdd(num1 As String, num2 As String, callback As AsyncCallback, asyncState As Object) As IAsyncResult
            Return Me.BeginInvoke("Add", Me.Url + "/Add", New Object() {num1, num2}, callback, asyncState)
        End Function 'BeginAdd


        Public Function EndAdd(asyncResult As IAsyncResult) As Integer
            Return CInt(Me.EndInvoke(asyncResult))
        End Function 'EndAdd
    End Class 'Math 
End Namespace 'MyMath

The following code example is the Math XML Web service, from which the above proxy class was created.

.NET Framework
Available since 1.1
Return to top
Show: