HttpSimpleClientProtocol.EndInvoke メソッド
アセンブリ: System.Web.Services (system.web.services.dll 内)

Dim asyncResult As IAsyncResult Dim returnValue As Object returnValue = Me.EndInvoke(asyncResult)
戻り値
XML Web サービス メソッドの戻り値や、参照渡しパラメータまたは out パラメータを格納しているオブジェクトの配列。


XML Web サービス (Math) を呼び出す ASP.NET Web フォームのコード例を次に示します。この Web フォームは、関数 EnterBtn_Click の中で、Add XML Web サービス メソッドの非同期呼び出しを開始して完了します。
<%@ 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>
<%@ Page Language="C#" %> <html> <script language="C#" runat="server"> void EnterBtn_Click(Object Src, EventArgs E) { MyMath.Math math = new MyMath.Math(); // Call the Add XML Web service method asynchronously. IAsyncResult result = math.BeginAdd(Convert.ToInt32(Num1.Text), Convert.ToInt32(Num2.Text), null, null); // Wait for the asynchronous call to complete. result.AsyncWaitHandle.WaitOne(); // Complete the asynchronous call to the Add XML Web service method. int total = math.EndAdd(result); Total.Text = "Total: " + total.ToString(); } </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>
Web サービス記述言語ツール (Wsdl.exe) によって、下の Math XML Web サービス用に生成されるプロキシ クラスのコード例を次に示します。EndInvoke メソッドは、プロキシ クラスの EndAdd メソッドの中で、Add XML Web サービス メソッドの非同期呼び出しを開始します。
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 'New <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
namespace MyMath { [XmlRootAttribute("int", Namespace="http://MyMath/", IsNullable=false)] public class Math : HttpGetClientProtocol { public Math() { this.Url = "http://www.contoso.com/math.asmx"; } [HttpMethodAttribute(typeof(System.Web.Services.Protocols.XmlReturnReader) , typeof(System.Web.Services.Protocols.UrlParameterWriter))] public int Add(int num1, int num2) { return ((int)(this.Invoke("Add", ((this.Url) + ("/Add")), new object[] {num1, num2}))); } public IAsyncResult BeginAdd(int num1, int num2, AsyncCallback callback, object asyncState) { return this.BeginInvoke("Add", ((this.Url) + ("/Add")), new object[] {num1, num2}, callback, asyncState); } public int EndAdd(IAsyncResult asyncResult) { return ((int)(this.EndInvoke(asyncResult))); } } }
namespace MyMath { [XmlRootAttribute("snippet1>",Namespace="http://MyMath/" ,IsNullable=false)] public ref class Math: public HttpGetClientProtocol { public: Math() { this->Url = "http://www.contoso.com/math.asmx"; } [HttpMethodAttribute(System::Web::Services::Protocols::XmlReturnReader::typeid , System::Web::Services::Protocols::UrlParameterWriter::typeid)] int Add( String^ num1, String^ num2 ) { array<Object^>^temp0 = {num1,num2}; return *dynamic_cast<int^>(this->Invoke( "Add", String::Concat( this->Url, "/Add" ), temp0 )); } IAsyncResult^ BeginAdd( String^ num1, String^ num2, AsyncCallback^ callback, Object^ asyncState ) { array<Object^>^temp1 = {num1,num2}; return this->BeginInvoke( "Add", String::Concat( this->Url, "/Add" ), temp1, callback, asyncState ); } int EndAdd( IAsyncResult^ asyncResult ) { return *dynamic_cast<int^>(this->EndInvoke( asyncResult )); } }; }

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- HttpSimpleClientProtocol.EndInvoke メソッドのページへのリンク