Below is a console sample Toolkit 3.0 finally gives the sample of VC6, 1.0 can only see VB and ASP
#include
#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; // Your machine has to install SOAP Toolkit 3.0, 1.0, use using namespace time
void Add () {ISoapSerializerPtr Serializer; ISoapReaderPtr Reader; ISoapConnectorPtr Connector; // Connect to the service Connector.CreateInstance (__ uuidof (HttpConnector30)); // HttpConnector30 failed, could not create this Connector, CXX0017 Error:. Symbol "HttpConnector30" not found (Shaking his head, sigh!) Connector-> Property ["endpointURL"] = "http://myserver/soap3docsample/docsample1/server/docsample1.wsdl"; // This is of course changed to your own pull connector-> connect );
// begin the message. // connection -> Property ["soapaction"] = "URI: addNumBers"; connection "] =" http://tempuri.org/docsample1/Action/sample1.addnumbers "" ""; ";
// Create the soapserializer object. Serializer.createInstance (__ uuidof (soapserializer30);
// Connect The Serializer Object To The Input Stream of The Connector Object. Serializer-> INIT (_VARIANT_T ((iunknown *) connector-> inputstream);
// buildate-> Startenvelope (",", ""); serializer-> startbody (""); serializer-> startelement ("addnumbers", "http://tempuri.org/docsample1 / message / ",", ""); // This is the local Web Services, actually specify the namespace Serializer-> StartElement ("Numberone", ",", ","); Serializer-> WritestRing ("5"); serializer-> endelement (); serializer-> StartElement ("NumberTwo", ",", ""); serializer-> WritestRing ("10"); serializer-> endelement (); Serializer -> endElement (); serializer-> endbody (); serializer-> endenvelope (); // send the message to the xml web service. Connector-> endMessage (); // readmedage (); // read the response. Reader.createInstance (__ uuidof) SOAPReader30));
// Connect The Reader to The Object. Reader-> Load (_VARIANT_T ((iUnknown *) connector-> outputstream), "")
// Display the result. Printf ("ANSWER:% S / N", (const char *) reader-> rpcResult-> text);}
INT main () {coinitialize (null); add (); couninitialize (); return 0;}
Change the value of the EndPointURL property. Specify your server name in the URL.
OK summarizes the necessary key steps 1. Import Type Library
2. Need to create a SOAPCONNECTOR
3. Next, create SOAPSERIALIZER
4. Next to attach the message to the input stream of SOAPConnector
5. Next, read the result. To read the reply of the server, the client application needs to use SoapReader.
6. SoapReader is connected to SOAPConnector output flow
7. Use the ixmldomelement object to read the server from SOAPReader