We help IT Professionals succeed at work.

SOAP Toolkit vc++ 6.0

rowlandk
rowlandk asked
on
Medium Priority
1,009 Views
Last Modified: 2008-01-09
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
Comment
Watch Question

Commented:
Hi rowlandk
this code do not have any error checking so please do first error checking. Because you did not check you code connect or not you just execute the connect command and suppose if your programme not connect so when you go to send or go to EndMessage then its give error.
So please make error checking and then run


Raj

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
Hi rowlandk
i think your problem solved.

Raj

Author

Commented:
I was unable to solve that specific problem, if you have an idea I would love to hear it.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.