HttpSimpleClientProtocol.BeginInvoke メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HttpSimpleClientProtocol.BeginInvoke メソッドの意味・解説 

HttpSimpleClientProtocol.BeginInvoke メソッド

XML Web サービスメソッド非同期呼び出し開始します

名前空間: System.Web.Services.Protocols
アセンブリ: System.Web.Services (system.web.services.dll 内)
構文構文

Protected Function BeginInvoke ( _
    methodName As String, _
    requestUrl As String, _
    parameters As Object(), _
    callback As AsyncCallback, _
    asyncState As Object _
) As IAsyncResult
Dim methodName As String
Dim requestUrl As String
Dim parameters As Object()
Dim callback As AsyncCallback
Dim asyncState As Object
Dim returnValue As IAsyncResult

returnValue = Me.BeginInvoke(methodName, requestUrl, parameters,
 callback, asyncState)
protected IAsyncResult BeginInvoke (
    string methodName,
    string requestUrl,
    Object[] parameters,
    AsyncCallback callback,
    Object asyncState
)
protected:
IAsyncResult^ BeginInvoke (
    String^ methodName, 
    String^ requestUrl, 
    array<Object^>^ parameters, 
    AsyncCallback^ callback, 
    Object^ asyncState
)
protected IAsyncResult BeginInvoke (
    String methodName, 
    String requestUrl, 
    Object[] parameters, 
    AsyncCallback callback, 
    Object asyncState
)
protected function BeginInvoke (
    methodName : String, 
    requestUrl : String, 
    parameters : Object[], 
    callback : AsyncCallback, 
    asyncState : Object
) : IAsyncResult

パラメータ

methodName

XML Web サービス メソッドの名前。

requestUrl

WebRequest を作成するときに使用する URL

parameters

XML Web サービス メソッドに渡すパラメータ格納しているオブジェクト配列配列内の値の順序は、呼び出し元の派生クラス メソッド渡されパラメータ順序対応してます。

callback

非同期メソッド呼び出し完了したときに呼び出されるデリゲートcallbacknull 参照 (Visual Basic では Nothing) の場合、このデリゲート呼び出されません。

asyncState

クライアントから提供され追加情報

戻り値
XML Web サービス メソッドからの戻り値取得するために、EndInvoke メソッドに渡すことのできる IAsyncResult。

例外例外
解説解説

methodName パラメータは、BeginInvoke メソッド呼び出しているメソッドパラメータおよび戻り値種類検索するために使用しますまた、メソッド追加されカスタム属性を見つけるためにも使用できます。SoapDocumentMethodAttribute、SoapRpcMethodAttribute、および XmlElementAttribute は、HTTP プロトコル必要な派生メソッドに関する追加情報提供します

asyncState は、callback渡されBeginInvoke メソッドから返される IAsyncResult中に含まれています。非同期呼び出しコンテキストからの情報を、callback非同期結果の処理に渡すには、便利です。

使用例使用例

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 サービス用に生成されるプロキシ クラスコード例次に示します。BeginInvoke メソッドは、プロキシ クラスBeginAdd メソッドの中で、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 ));
      }
   };
}

前述プロキシ クラス作成元の Math XML Web サービスコード例次に示します

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

Public Class Math
    <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="Math"%>
 using System.Web.Services;
 using System;
 
 public class Math {
      [ WebMethod ]
      public int Add(int
 num1, int num2) {
          return num1+num2;
          }
 }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HttpSimpleClientProtocol クラス
HttpSimpleClientProtocol メンバ
System.Web.Services.Protocols 名前空間
IAsyncResult


このページでは「.NET Framework クラス ライブラリ リファレンス」からHttpSimpleClientProtocol.BeginInvoke メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からHttpSimpleClientProtocol.BeginInvoke メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からHttpSimpleClientProtocol.BeginInvoke メソッド を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

HttpSimpleClientProtocol.BeginInvoke メソッドのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



HttpSimpleClientProtocol.BeginInvoke メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS