SOAP client using c++ - How to do.

Hi,

Anyone here has any experience in SOAP using c++.
I am building a SOAP client and want to send SOAP/xml to http server and not really getting how it will be done. Normal requests to the server are returning successfully but that's easy. I can send the whole XML to the server but dont know at what step or what sequence i have to follow to make it successful.

In the normal circumstances we send a simple http request to the server after establishing connection. Will we be sending the whole xml/soap in this case to the server instead? I am open to using any cross platform libraries also if there is one.

Thanks.
Last edited on
try using gsoap.. it will be very simple to process both the client and server request..
some secondary library will be my last option.. i have some code ready and will try to use that first..
have you used soap before?
just to move it to the top so that some can see my question. :P
Solved :)

for someone who wants to implement SOAP using c++:
SOAP is a protocol to send data to a web server/service and get response.
the packet should be http + xml

http:
"POST <page> HTTP/1.1\r\n";
"Host: <host_address> \r\n";
"Content-Type: text/xml; charset=ISO-8859-1\r\n";
"SOAPAction: \r\n";
"Content-Length: <length of the xml> \r\n";
"Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n";
"Connection: keep-alive\r\n\r\n";


host will be: www.ebob42.com (for this example)
soapaction is not necessary but sometimes used
content length is the full length of the xml below
pags will be whatever is there after the domain name, like if the whole link is:
www.ebob42.com/cgi-bin/Romulan.exe/soap/IRoman
then page will be /cgi-bin/Romulan.exe/soap/IRoman


xml will be the whole soap request like this which i used to test:
1
2
3
4
5
6
7
8
9
10
11
12
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:n="x">
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <n:IntToRoman>
            <Int xsi:type="soapenc:long">1992</Int>
        </n:IntToRoman>
    </soap:Body>
</soap:Envelope>


so the packet will contain the full packet, http + xml which i have shown above.
i opened
www.ebob42.com
this using socket and wrote the whole thing and accepted the reply which was something like this:

Content-Length: 503
Content-Type: text/xml
Server: Microsoft-IIS/6.0
Content:
X-Powered-By: ASP.NET
Date: Wed, 11 Nov 2009 11:23:42 GMT

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
<NS1:IntToRomanResponse xmlns:NS1="urn:Roman-IRoman">
<return xsi:type="xsd:string">MCMXCII</return>
</NS1:IntToRomanResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


what it is doing is when i send the server a request giving it a number it will return me its equivalent roman number. i have send 1992 and it returned MCMXCII.

thats it and you have learned how to send SOAP request using C++.
Last edited on
Topic archived. No new replies allowed.