HttpSimpleClientProtocol::Invoke Method (String^, String^, array<Object^>^)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Invokes an XML Web service method using HTTP.

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

Object^ Invoke(
	String^ methodName,
	String^ requestUrl,
	array<Object^>^ parameters


Type: System::String^

The name of the XML Web service method in the derived class that is invoking the Invoke method.

Type: System::String^

The URL of the XML Web service method that the client is requesting.

Type: array<System::Object^>^

An array of objects containing the parameters to pass to the remote XML Web service. The order of the values in the array corresponds to the order of the parameters in the calling method of the derived class.

Return Value

Type: System::Object^

An array of objects containing the return value and any by-reference or out parameters of the derived class method.

Exception Condition

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 Invoke method. It is also used to find custom attributes which may have been added to the method. HttpMethodAttribute and XmlElementAttribute provide additional information on the derived method that is required for the SOAP protocol.

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 synchronously invokes the Add XML Web service method.

No code example is currently available or this language may not be supported.

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 Add method of the proxy class, the Invoke method synchronously invokes the Add Web Service method.

#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

   public ref class Math: public System::Web::Services::Protocols::SoapHttpClientProtocol

         this->Url = "";

      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::IAsyncResult^ BeginAdd( int num1, int num2, System::AsyncCallback^ callback, Object^ asyncState )
         array<Object^>^temp1 = {num1,num2};
         return this->BeginInvoke( "Add", temp1, callback, asyncState );

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



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