How to connect to web service from C++

M

Manjunath.M

Hi,

I have created a simple Web service with only one function, which
takes only one parameter.
Below is the function from Web service
[WebMethod]
public string HelloWorld(string input)
{
return "Hello World"+input+"Here";
}
I am trying to access to this function from C++.Below is the Code

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));

Connector->Property["EndPointURL"] = "http://localhost/FinalService/
Service1.asmx";
Connector->Connect();
// Begin message
Connector->Property["SoapAction"] = "http://tempuri.org/HelloWorld";
Connector->BeginMessage();
// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer));
// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// Build the SOAP Message

Serializer->startEnvelope("","","");
Serializer->startBody("");
Serializer->startElement("HelloWorld","http://tempuri.org/
HelloWorld","","m");
Serializer->startElement("input","","","");
Serializer->writeString( "Test");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();

// Send the message to the web service
Connector->EndMessage();
#################################################################

But here C++ code is passing the empty value to the Web service
because whn I display
the o/p is "Hello WorldHere".
I am expecting "Hello WorldTestHere". but it is not displaying.

Please can any one tell me how to pass the parameter value?

Thanks,
Manjunath.M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top