HttpSimpleClientProtocol::BeginInvoke Method
Starts an asynchronous invocation of a method of an XML Web service.
Assembly: System.Web.Services (in System.Web.Services.dll)
protected: IAsyncResult^ BeginInvoke( String^ methodName, String^ requestUrl, array<Object^>^ parameters, AsyncCallback^ callback, Object^ asyncState )
Parameters
- methodName
- Type: System::String
The name of the XML Web service method.
- requestUrl
- Type: System::String
The URL to use when creating the WebRequest.
- parameters
- Type: array<System::Object>
An array of objects containing the parameters to pass to the XML Web service method. The order of the values in the array corresponds to the order of the parameters in the calling method of the derived class.
- callback
- Type: System::AsyncCallback
The delegate to call when the asynchronous method call is complete. If callback is nullptr, the delegate is not called.
- asyncState
- Type: System::Object
The additional information supplied by a client.
Return Value
Type: System::IAsyncResultAn IAsyncResult that can be passed to the EndInvoke method to obtain the return values from the XML Web service method.
| Exception | Condition |
|---|---|
| Exception | The request reached the server computer, but was not processed successfully. |
The methodName parameter is used to find the types of the parameters and return values of the method that is invoking the BeginInvoke method. It is also used to find custom attributes that may have been added to the method. SoapDocumentMethodAttribute, SoapRpcMethodAttribute, and XmlElementAttribute provide additional information on the derived method that is required for the HTTP protocol.
asyncState is passed into callback and is included in the IAsyncResult that is returned from the BeginInvoke method. It is useful for passing information from the context of the asynchronous call to the handling of the asynchronous result in callback.
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.
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 BeginAdd method of the proxy class, the BeginInvoke method starts an asynchronous invocation of the Add XML Web service method.
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 )); } }; }
The following code example is the Math XML Web service, from which the preceding proxy class was created.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.