Vc6 Web Services Client development

Source: Internet
Author: User

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"] = " ";
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", "", "", ""); // 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.


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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.