Link to home
Start Free TrialLog in
Avatar of rowlandk
rowlandk

asked on

SOAP Toolkit vc++ 6.0

I am having some problems connecting to web services with soap through c++ I have looked at numerous examples and followed the help documentation from microsofts SOAP Toolkit.  I have also tried using the webreferences feature of .net.

My problem is that I have to develop in c++ and add SOAP services to an application.  I have been using the following example code from code guru.

#include <stdio.h>

#import "msxml4.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap30.dll" \
exclude("IStream", "IErrorInfo", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib30;

void main()
{
CoInitialize(NULL);

ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;

// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector30));
Connector->Property["EndPointURL"] =
"http://www.allesta.net:51110/webservices/soapx4/isuseronline.php";;
Connector->Connect();

// Begin message
Connector->Property["SoapAction"] = "uri:allesta-YahooUserPing";
Connector->BeginMessage();

// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer30));

// 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("isuseronline",
"uri:allesta-YahooUserPing",
"",
"m");
Serializer->StartElement("username","","","");
Serializer->WriteString("laghari78");
Serializer->EndElement();
Serializer->EndElement();
Serializer->EndBody();
Serializer->EndEnvelope();

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

// Read the response
Reader.CreateInstance(__uuidof(SoapReader30));

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

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

}

All I get is an abnormal program termination message.

I have SOAPToolkit 3.0 installed and I have MSXML4 installed.  If anyone could point me in the right direction or give me an idea why this might be crashing it would be very appreciated.  It seems to be crashing at the EndMessage line.  I have tried numerous url's which cause earlier crashes at the Property["EndPointUrl"] line.

Thanks
Kurt
ASKER CERTIFIED SOLUTION
Avatar of Raj_Kau
Raj_Kau

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Raj_Kau
Raj_Kau

Hi rowlandk
i think your problem solved.

Raj

Avatar of rowlandk

ASKER

I was unable to solve that specific problem, if you have an idea I would love to hear it.