Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

C++ Soap program to access web service EndMessage problem

Paul77Paul77 Member Posts: 2


Hi,
I'm trying to write a C++ soap client to access one of the
soapclient.com web services, the soap responder service, which
echoes back the two input paramaters. The code compiles but throws
an error on the EndMessage function to send the soap message - the code is listed below - does anyone have any ideas as to why the message is not being accepted - I have guessed at one or two items - eg I've set the SoapAction parameter to "" and I believe method should be set to Method1.

Thanks
Paul



#include

#import "msxml3.dll"
using namespace MSXML2;

#import "C:Program FilesCommon FilesMSSoapBinariesMSSOAP1.dll"
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER",
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;

void CallService()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = "http://soapclient.com/xml/soapresponder.wsdl";
Connector->Connect();

// Begin message
Connector->Property["SoapAction"] = "";
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("Method1","","","m");
Serializer->startElement("bstrParam1","","","");

Serializer->writeString("text");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();


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

// Let us read the response
Reader.CreateInstance(__uuidof(SoapReader));

// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");

// Display the result
printf("Answer: %s
", (const char *)Reader->RPCResult->text);

}

void main()
{
CoInitialize(NULL);
CallService();
CoUninitialize();
}


Sign In or Register to comment.