The sample demonstrates how to write a SOAP client
application using SQLData SOAP Client library. It accesses the web service at http://www.soapclient.com and calls Method1
to get
TestSoapClient()
{
// initialize the parameter array for the method call. The array must end with NULL.
TCHAR* pParams[3]={"My First Param", "My Second Param", NULL};
// create an soapagent in debug mode (mode=4)
SoapAgent *pSoapAgent= MakeSoapAgent(NULL, NULL, 4);
if(pSoapAgent==NULL)
return -1;
std::string * pOutput;
unsigned int nSize=0;
HRESULT hr; // invoke the remote method
if(SUCCEEDED(hr=pSoapAgent->ExecuteMethod(
"http://www.soapclient.com/xml/soapresponder.wsdl", // WSDL file
"Method1", // method name to be invoked.
pParams, // array of input parameters.
&pOutput, // array of output parameters
&nSize // number of output variable in pOutput
)))
{
// print out results
for(int i=0; i<nSize; i++)
_tprintf("%s\n", pOutput[i].c_str());
}
else
{
// obtain error string when failed.
_tprintf("Error String %s\n", pSoapAgent->GetErrorString());
}
DestroySoapAgent(pSoapAgent);
return 0;
}You can also access web services in Visual Basic or Active Server Pages using our SoapAgent object. The following is all you need to get a stock quote: Dim MyAgent As SoapAgent
Set MyAgent = New SoapAgent
MyAgent.AddParameter "symbol", "msft", ""
MyAgent.ExecuteMethod "http://services.xmethods.net/soap/urn:xmethods-delayed-quotes.wsdl", "getQuote"
MsgBox MyAgent.GetResponse("Result")
Please visit http://www.SoapClient.com
for more information and sample applications. |
|
Send mail to info2-at-sqldata-dot-com with questions or comments about
this web site.
|