The following is an example of the console.
Toolkit3.0 finally gave a sample of vc6. 1.0 only visible to VB and ASP
# 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; // your machine must install soap toolkit3.0, 1.0, and an error is reported using namespace
Void add ()
{
Isoapserializerptr serializer;
Isoapreaderptr reader;
Isoapconnectorptr connector;
// Connect to the service.
Connector. createinstance (_ uuidof (httpconnector30 ));// Httpconnector30 fails. You cannot create a ctor like this. cxx0017 error: Symbol "httpconnector30" not found (shake your head and sigh !)
Connector-> property ["endpointurl"] = "http: // myserver/soap3docsamples/docsample1/Server/docsample1.wsdl"; // you must change this to your own pull.
Connector-> connect ();
// Begin the message.
// Connector-> property ["soapaction"] = "URI: addnumbers ";
Connector-> property ["soapaction"] = "http://tempuri.org/DocSample1/action/Sample1.AddNumbers ";
Connector-> beginmessage ();
// 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 ));
// build the SOAP message.
serializer-> startenvelope ("", "", "");
serializer-> startbody ("");
serializer-> startelement ("addnumbers", "http://tempuri.org/DocSample1/message/", "", ""); // This is a local web service, actually, you must specify the namespace
serializer-> startelement ("numberone ","","","");
serializer-> writestring ("5");
serializer-> endelement ();
serializer-> startelement ("numbertwo ","", "", "");
serializer-> writestring ("10");
serializer-> endelement ();
serializer-> endbody ();
serializer-> endenvelope ();
// send the message to the XML Web Service.
connector-> endmessage ();
// Read the response.
Reader. createinstance (_ uuidof (soapreader30 ));
// Connect the reader to the output stream of the connector 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 attribute. Specify your server name in the URL.
OK
Summarize the necessary key steps
1. Import Type Library
2. Create a soapconnector
3. Create soapserializer
4. Next, append the message to the input stream of soapconnector.
5. Read the result in the next step. to read the server's reply, the client application must use soapreader,
6. soapreader is connected to the soapconnector output stream.
7. The ixmldomelement object can be used to read server replies from soapreader.