SOAP Client Using Visual C++

Environment: Visual C++ 6.0, Windows 98/NT/2000

Section 1: Introduction

In this article, I'll show you how to build a SOAP client using Visual C++. This tutorial gives you a hands-on introduction to using the SOAP API. SOAP is emerging as a very popular protocol for exchanging information. It's relatively simple and designed to work with HTTP, SMTP, and other such protocols.

Prerequisites:

You should be familiar with using COM, specially using Smart Pointers in COM as I used an import directive to convert COM interfaces to Smart Pointers. You must have the Microsoft SOAP Toolkit installed on your system. For information on downloading the toolkit, see the Resources section later in this article.

Section 2: Fundamentals of SOAP Programming

I'll start with the introduction of the classes involved in a basic SOAP Application. Before that, we have to import the required type libraries so that our program can use the SOAP classes.

Importing Type libraries:

All the objects and interfaces used in SOAP are found in mssoap1.dll. This file is installed with the Microsoft SOAP Toolkit 2.0. You can find this file in "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll". All you have to do is to import this file into your source using the #import directive, which is used to incorporate information from a type library. The contents of the type library are converted into COM smart pointers, describing the COM interfaces. Because SOAP relies completely on XML, the Microsoft XML Parser is also needed for XML processing. The Microsoft XML parser is included in msxml#.dll where # is the version number. Again, you need to import this file before importing mssoap1.dll.

#import "msxml3.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;

That is all that is needed to include all class definitions required to develop a SOAP program. There are three steps that are necessary to make a SOAP client.

  • Specify and connect with the Web Service
  • Prepare and send the message
  • Read the response back from the Service

Now, let's take a look at the classes involved. Following are the classes that are used to develop a basic SOAP client.

Class 1 -- SoapConnector:

The first thing that is required for any client in a client/ server application is to connect with the server. The SoapConnector class implements the protocol that is used as a transport between the client and the server. SoapConnector acts as an abstract class for defining the interface for implementing other protocols. That is because SOAP is not limited to a specific protocol; you'll see that some implementation supports MSMQ, MQ Series, SMTP, and TCP/IP Transports. For the sake of simplicity, I am demonstrating the use of HTTP Transport, which is implemented by the HttpConnector class available with the Microsoft SOAP Toolkit 2.0.

The steps involved in using SoapConnector class

a) Creating an object to SoapConnector:

ISoapConnectorPtr connector;
Connector.CreateInstance(__uuidof(HttpConnector)); 

b) Specifying the Web Service Address:

Next, we have to define the Web service that we are using as a client. The service is specified using the Property (an attribute of HttpConnector). There are two things to specify when dealing with this attribute:

  • Which property are we referring to
  • the value of the respective property type

Here, for specifying the Web service, we use the EndPointURL property.

Connector->Property ["EndPointURL"] = 
               "some url pointing to web service";

The following table provides a list of properties. (The property names are case sensitive.)

Property
Description
AuthPassword
The password used for end point authentication.
AuthUser
The user name used for end point authentication.
EndPointURL
The end point URL.
ProxyPassword
The password used for proxy authentication.
ProxyPort
The port of the proxy server to use.
ProxyServer
The IP address or host name of the proxy server.
ProxyUser
The user name used for proxy authentication.
SoapAction
The value used in the "SoapAction" HTTP header. This property can be set only from the low-level API. It is ignored if the property is set using the ConnectorProperty property of the SoapClient interface (high-level API).
SSLClientCertificateName
A string identifying the client certificate to use for the Secure Sockets Layer (SSL) protocol, if any. The syntax is:
[CURRENT_USER | LOCAL_MACHINE\[store-name\]]cert-name with the defaults being CURRENT_USER\MY (the same store that Microsoft Internet Explorer uses).
Timeout
The timeout for HttpConnector. This timeout is in milliseconds.
UseProxy
A Boolean property that specifies whether a to use a proxy server. By default, this property is set to False, indicating that a proxy server should not be used. Set this property to True if you want to use a proxy server.
If you set this property to True and don't specify the ProxyServer property, the HttpConnector uses the proxy server set in the default settings of Microsoft® Internet Explorer. In this release, the HttpConnector ignores the "Bypass Proxy" settings in Internet Explorer.
UseSSL
A Boolean value (True or False) that specifies the use of SSL.
If this property is set to True, the HttpConnector object uses SSL connection regardless of whether HTTP or HTTPS is specified in the WSDL. If this property is set to False, the HttpConnector object will use SSL connection only if HTTPS is specified in the WSDL.

( The above table is taken from MSDN )

c) Connecting with the Web Service:

The connect method of HttpConnector is used to initialize the SoapConnector object and actually prepares a connection with the service.

Connector->Connect();

d) Specifying the action:

After connecting with the server, we need to specify the action that we are going to perform on the Web service. To specify the Action, we again use the Property attribute of the soapConnector.

Connector->Property ["SoapAction"] = "some uri";

e) Message handling:

After connecting with the service and specifying other details, we signal the start of a SOAP message being sent to the server. The function must be called before calling any other method of SoapSerializer ( which is used to prepare the message).

Connector->BeginMessage();

After finishing the message, we must call the EndMessage() function to actually send the message to the service.

.
.
[ message preparation code ]
.
.
Connector->EndMessage();

This is all that is needed to actually connect with the service. The next part shows you how to create and prepare a message.

SoapSerializer:

The SoapSerializer is used to build a SOAP message to be sent to the service. The SoapSerializer object must be connected with the SoapConnector object before communicating with the server. To interconnect these two objects, we need to call the Init method of the SoapSerializer object. This method takes a single argument, which is the InputStream (the stream the sends data to the server).

// creating a SoapSerializer object and initializing it 
// with InputSTream
ISoapSerializerPtr Serializer; 
Serializer.CreateInstance(_uuidof(SoapSerializer)); 
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

Before looking into other functions of SoapSerializer, let's take a look at a sample SOAP request to get an idea of what we are building in our code.

Simple Soap Request:

<SOAP: Envelope xmlns:SOAP="soap namespace">
<SOAP:Body>
<m:someMethodName xmlns:m="some namespace"> 
<someParameter> </someParameter> </SOAP:Body></SOAP: Envelope> 
<SOAP: Envelope xmlns:SOAP="soap namespace">
<SOAP:Body>
<m:someMethodName xmlns:m="some namespace">
<someParameter> someParameterValue </someParameter>
<m:someMethodName>
</SOAP:Body>
</SOAP: Envelope>

A SOAP request is simply encapsulated into tags. The <Envelope> tag is the main tag of this SOAP Document. A SOAP message is always encapsulated in an envelope. The envelope contains a message body, which is specified by a <Body> Tag. The body contains the actual request. In C++, we have the appropriate methods to create these tags and specify any values in these. The following code piece demonstrates the use of these methods.

Serializer->startEnvelope("SOAP","","");
  // Begins an <envelope> element in a SOAP message, first 
  // the argument defines the namespace. If it is empty, SOAP-ENV
  // is used by default.
  // The second and the third argument define the URI and the
  // Encoding Type, respectively. Serialzier->startBody("");
  // begins the <Body> element in the message. The first
  // argument defines the encoding style Uri; by default it is NONE.
Serializer->startElement("someMethodName","","","m");
  // Begins a child element into the body element of a SOAP message.
  // The first parameter is the element name; the second parameter is
  // the Uri; the third is the encoding style; and the last element
  // is the namespace for the element.
Serializer->WriteString("someParameterValue")
  // Writes the value of an element.

All the preceding startXXX functions have their equivalent endXXX function to end the element. After finishing the message, the connector's endMessage() method is called to actually send the message as described above.

Until here in this tutorial, we have connected with the service, prepared our request, and sent it to service. The next and the final step is to read the response from the server.

SoapReader:

This object reads the response from the service and parses the incoming message into DOM for further processing. Following is a sample SOAP Response from the service.

Simple SOAP Response:

  <SOAP: Envelope xmlns:SOAP="soap namespace">
  <SOAP:Body>
  <m:someMethodNameResponse xmlns:m="some namespace">
  <return> someResult </return>
  <m:someMethodNameResponse>
  </SOAP:Body>
  </SOAP: Envelope>

Before calling any functions to get the result, we connect with the OutputStream to actually read the response in a SoapReader object. ( An OutputStream receives data from the service ).

// code to create a SOAPReader object and connecting with
// the outputstream 
ISoapReaderPtr Reader; Reader.CreateInstance(_uuidof(SoapReader));
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream)); 

// the load method can also accept a XML Document File or String

After loading the response into our SoapReader object, we get the result by calling the RPCResult property of SoapReader object. But RPCResult doesn't return the actual result; it returns the first child element of the first entry in the <Body> element. We get the result by calling the text property.

Reader->RPCResult->text

Section 3: Demonstrating a Sample SOAP Client

For demonstrating the use of above SOAP classes, I used one of the services listed on www.xmethods.net. The service indicates Yahoo Messenger's online presence. You can find the required details by following this URL: http://www.xmethods.net/ve2/ViewListing.po?serviceid=156. The only thing it expects is a method parameter, such as the Yahoo user's login id. The result returned is a Boolean value indicating 0 for offline and 1 for online. Other details are available on the site or by viewing the wsdl at http://www.allesta.net:51110/webservices/wsdl/YahooUserPingService.xml.

Section 4: Resources

The SOAP specification Simple Object Access Protocol (SOAP) 1.1 - W3C Note

http://www.w3.org/TR/SOAP

Microsoft SOAP Toolkit Download

http://download.microsoft.com/download/xml/soap/2.0/w98nt42kme/EN-US/SoapToolkit20.exe

Source Code:

#include <stdio.h>

#import "msxml3.dll" 
using namespace MSXML2;

#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;

void main()
{
  CoInitialize(NULL);

  ISoapSerializerPtr Serializer;
  ISoapReaderPtr Reader;
  ISoapConnectorPtr Connector;

  // Connect to the service
  Connector.CreateInstance(__uuidof(HttpConnector));
  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(SoapSerializer));

  // 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(SoapReader));

  // 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();

}

Downloads

Download demo project -- 3.18 KB



Comments

  • Web Serice fails to form a proper packet

    Posted by Pankaj on 06/30/2017 02:55am

    #import "msxml6.dll" #import "C:\Program Files (x86)\Common Files\MSSoap\Binaries\MSSOAP1.dll" exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME") using namespace MSSOAPLib; /*#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \ exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \ "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")*/ using namespace MSSOAPLib; #include #include #include void CallService() { ISoapSerializerPtr Serializer; ISoapReaderPtr Reader; ISoapConnectorPtr Connector; HRESULT hr; // Connect to the service try { Connector.CreateInstance(__uuidof(HttpConnector)); //Connector.CreateInstance(__uuidof(HttpConnector)); Connector-Property["EndPointURL"] = "http://localhost:59598/WebService.asmx";//"http://www.allesta.net:51110/webservices/soapx4/isuseronline.php"; //"http://localhost:59598/WebService.asmx";//http://localhost:59598/WebService.asmx/ConvertTemperature hr = Connector-Connect(); // Begin message Connector-Property["SoapAction"] = "WebServiceSoap";////BSTR action = L"SoapAction";//WebServiceSoap hr = Connector-BeginMessage(); //http://localhost:59598/WebService.asmx/ConvertTemperature // Create the SoapSerializer hr = Serializer.CreateInstance(__uuidof(SoapSerializer)); // Connect the serializer to the input stream of the connector hr = Serializer-Init(_variant_t((IUnknown*)Connector-InputStream)); // Build the SOAP Message hr = Serializer-startEnvelope("","",""); hr = Serializer-startBody(""); //hr = Serializer-startElement("ConvertTemperature","http://localhost:59598/WebService.asmx","","m"); hr = Serializer-startElement("ConvertTemperature","http://localhost:59598/WebService.asmx", //"http://localhost:59598/WebService.asmx", "", "m"); hr = Serializer-startElement("ConvertTemperature","","",""); //hr = Serializer-startElement("m:ConvertTemperature","","","m"); //hr = Serializer-startElement("ConvertTemperature",atoi("http://localhost:59598/WebService.asmx/ConvertTemperature","","m"); //hr = Serializer-startElement("username","","",""); hr = Serializer-writeString("10"); // hr = Serializer-writeXML((_bstr_t)"123"); hr = Serializer-endElement(); hr = Serializer-endElement(); hr = Serializer-endBody(); hr = Serializer-endEnvelope(); // Send the message to the web service hr = Connector-EndMessage(); // Let us read the response hr = Reader.CreateInstance(__uuidof(SoapReader)); // Connect the reader to the output stream of the connector hr = Reader-Load(_variant_t((IUnknown*)Connector-OutputStream), ""); // Display the result printf("Answer: %s\n", (const char *)Reader-RPCResult-text);//MSSOAP.SoapReader.1 } //catch(catch (_com_error& e)) catch(...) { printf("Error = %x", GetLastError()); } } void main() { CoInitialize(NULL); CallService(); CoUninitialize(); }

    Reply
  • Failed to get response of soap packet

    Posted by Pankaj on 06/30/2017 02:53am

    Dear Programmers, I made a vb web service and published locally. My main motive was to invoke a web method with 'in' parameter. It was working fine. I was required to call this service through a C++ code....then I tried your code. Compilation was fine...but at the return value getting as "Answer: soap:Client" means SOAP packet is failing.....I only replaced your url code with my web service url...as "http://localhost:59598/WebService.asmx" and method name as "ConvertTemperature"...full url is "http://localhost:59598/WebService.asmx/ConvertTemperature"...using yur code my packet is not coming properly....I dont know what is wrong....here is code:- #import "msxml6.dll" #import "C:\Program Files (x86)\Common Files\MSSoap\Binaries\MSSOAP1.dll" exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME") using namespace MSSOAPLib; /*#import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \ exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \ "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")*/ using namespace MSSOAPLib; #include #include #include void CallService() { ISoapSerializerPtr Serializer; ISoapReaderPtr Reader; ISoapConnectorPtr Connector; HRESULT hr; // Connect to the service try { Connector.CreateInstance(__uuidof(HttpConnector)); //Connector.CreateInstance(__uuidof(HttpConnector)); Connector-Property["EndPointURL"] = "http://localhost:59598/WebService.asmx";//"http://www.allesta.net:51110/webservices/soapx4/isuseronline.php"; //"http://localhost:59598/WebService.asmx";//http://localhost:59598/WebService.asmx/ConvertTemperature hr = Connector-Connect(); // Begin message Connector-Property["SoapAction"] = "WebServiceSoap";////BSTR action = L"SoapAction";//WebServiceSoap hr = Connector-BeginMessage(); //http://localhost:59598/WebService.asmx/ConvertTemperature // Create the SoapSerializer hr = Serializer.CreateInstance(__uuidof(SoapSerializer)); // Connect the serializer to the input stream of the connector hr = Serializer-Init(_variant_t((IUnknown*)Connector-InputStream)); // Build the SOAP Message hr = Serializer-startEnvelope("","",""); hr = Serializer-startBody(""); //hr = Serializer-startElement("ConvertTemperature","http://localhost:59598/WebService.asmx","","m"); hr = Serializer-startElement("ConvertTemperature","http://localhost:59598/WebService.asmx", //"http://localhost:59598/WebService.asmx", "", "m"); hr = Serializer-startElement("ConvertTemperature","","",""); //hr = Serializer-startElement("m:ConvertTemperature","","","m"); //hr = Serializer-startElement("ConvertTemperature",atoi("http://localhost:59598/WebService.asmx/ConvertTemperature","","m"); //hr = Serializer-startElement("username","","",""); hr = Serializer-writeString("10"); // hr = Serializer-writeXML((_bstr_t)"123"); hr = Serializer-endElement(); hr = Serializer-endElement(); hr = Serializer-endBody(); hr = Serializer-endEnvelope(); // Send the message to the web service hr = Connector-EndMessage(); // Let us read the response hr = Reader.CreateInstance(__uuidof(SoapReader)); // Connect the reader to the output stream of the connector hr = Reader-Load(_variant_t((IUnknown*)Connector-OutputStream), ""); // Display the result printf("Answer: %s\n", (const char *)Reader-RPCResult-text);//MSSOAP.SoapReader.1 } //catch(catch (_com_error& e)) catch(...) { printf("Error = %x", GetLastError()); } } void main() { CoInitialize(NULL); CallService(); CoUninitialize(); } Any suggestion would be highly appreciated. -Pankaj

    Reply
  • XML string

    Posted by Tom on 11/07/2014 02:08am

    Hi, how I can send prepared XML string between Connector-BeginMessage() and Connector-EndMessage() without Serializer ? Tom

    Reply
  • How to create sope service envlop with header and body with credential in VC++ code

    Posted by denbert on 05/01/2012 04:17am

    Please let me know if some one have the solution. How to create sope service envlop with header and body with credential in VC++ code

    Reply
  • return incorrect value

    Posted by zrahimic on 02/20/2006 06:02am

    hi,
    I wrote this code in VC++ 6. my program should be connecting to localhost and execute a function from .Net WebService. but its result value was "soap:clien".
    
    my code is:
    
       CString strResult,
    	  strTemp,
    	  strUri;
    
       _bstr_t bstrUri;
    
       CoInitialize( NULL );
       poiConnector.CreateInstance( __uuidof( HttpConnector ) );
       poiConnector -> Property[ "EndPointURL" ] = "http://localhost/WebService1/Service1.asmx";
       poiConnector -> Connect();
    
       bstrUri = "uri:http://localhost/WebService1";
       poiConnector -> Property["SoapAction"] = bstrUri;
       poiConnector -> BeginMessage();
    
       poiSerializer.CreateInstance( __uuidof( SoapSerializer ) );
    
       poiSerializer -> Init( _variant_t( ( IUnknown * )poiConnector -> InputStream ) );
    
       poiSerializer -> startEnvelope( "", "", "" );
       poiSerializer -> startBody( "" );
       poiSerializer -> startElement( "ReverseString", bstrUri, "", "" );
       poiSerializer -> startElement( "strMessage", "", "", "" );
       poiSerializer -> writeString( strInput.AllocSysString() );
       poiSerializer -> endElement();
       poiSerializer -> endElement();
       poiSerializer -> endBody();
       poiSerializer -> endEnvelope();
       
       poiConnector -> EndMessage();      
    
       poiReader.CreateInstance( __uuidof( SoapReader ) );
    
       poiReader -> Load( _variant_t( ( IUnknown * )poiConnector -> OutputStream ), "" );
    
       IXMLDOMElement *poiResult;
       poiReader -> get_RPCResult( &poiResult );
       strResult = ( LPCSTR )(poiResult ->text);
    
       poiReader.Release();
       poiSerializer.Release();
       poiConnector.Release();
       CoUninitialize();
    
       return strResult; 
    
    its error is :
    " soap:Client
    System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://localhost/WebServices/.
       at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()"
    
    can u help me?
    
    thnx

    Reply
  • return incorrect value

    Posted by zrahimic on 02/20/2006 06:00am

    hi,
    I wrote this code in VC++ 6. my program should be connecting to localhost and execute a function from .Net WebService. but its result value was "soap:clien".
    
    my code is:
    
       CString strResult,
    	  strTemp,
    	  strUri;
    
       _bstr_t bstrUri;
    
       CoInitialize( NULL );
       poiConnector.CreateInstance( __uuidof( HttpConnector ) );
       poiConnector -> Property[ "EndPointURL" ] = "http://localhost/WebService1/Service1.asmx";
       poiConnector -> Connect();
    
       bstrUri = "uri:http://localhost/WebService1";
       poiConnector -> Property["SoapAction"] = bstrUri;
       poiConnector -> BeginMessage();
    
       poiSerializer.CreateInstance( __uuidof( SoapSerializer ) );
    
       poiSerializer -> Init( _variant_t( ( IUnknown * )poiConnector -> InputStream ) );
    
       poiSerializer -> startEnvelope( "", "", "" );
       poiSerializer -> startBody( "" );
       poiSerializer -> startElement( "ReverseString", bstrUri, "", "" );
       poiSerializer -> startElement( "strMessage", "", "", "" );
       poiSerializer -> writeString( strInput.AllocSysString() );
       poiSerializer -> endElement();
       poiSerializer -> endElement();
       poiSerializer -> endBody();
       poiSerializer -> endEnvelope();
       
       poiConnector -> EndMessage();      
    
       poiReader.CreateInstance( __uuidof( SoapReader ) );
    
       poiReader -> Load( _variant_t( ( IUnknown * )poiConnector -> OutputStream ), "" );
    
       IXMLDOMElement *poiResult;
       poiReader -> get_RPCResult( &poiResult );
       strResult = ( LPCSTR )(poiResult ->text);
    
       poiReader.Release();
       poiSerializer.Release();
       poiConnector.Release();
       CoUninitialize();
    
       return strResult; 
    
    can u help me?
    
    thnx

    Reply
  • Code Update, to use with MSXML4, and, MSSOAP3

    Posted by Legacy on 10/13/2003 12:00am

    Originally posted by: Ranganath


    Hi,

    Below is the code update, to use with MSXML4, and, MSSOAP3. Nothing has been changed.


    Regards,
    Ranganath
    branganath@yahoo.com


    #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();

    }

    Reply
  • How to send the binary data in base64binaray

    Posted by Legacy on 06/25/2003 12:00am

    Originally posted by: Phil

    Dear all:

    I modified the example to send data in type string and it worked fine . But failed in type base64binary . Does any one know the way to send binary data in VC++?
    Or any sample code about use DIME to transfer binary data in VC++.

    Best Regards,
    Phil.

    Reply
  • why this path ?

    Posted by Legacy on 06/16/2003 12:00am

    Originally posted by: Luc

    Good job, yes ; very good !!
    
    

    a question however: why specify this abslolute path !!


    #import "C:\Program Files\Common Files\MSSoap\Binaries\MSSOAP1.dll" \
    exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
    "_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
    using namespace MSSOAPLib;


    to have a client SOAP, must I have a full install of SOAP Toolkit or just the MSSOAP#.dll with its depends ?

    thanks

    Reply
  • very good!! Is there same code with VB?

    Posted by Legacy on 05/19/2003 12:00am

    Originally posted by: Hye Sook, Lee

    Thank you for your good instruction.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date