cURL / Mailing Lists / curl-library / Single Mail

curl-library

Receiving SOAP response in libcurl

From: abhishek Kalapatapu <abhisrk_at_gmail.com>
Date: Mon, 12 Sep 2011 17:39:02 -0700

Hello,

Since two days I have been working on libcurl and the forum has helped me in
understanding quite a few stuff. Thanks a lot. Now I saw the http-post
example and created a SOAP request and sending it via (CURLOPT_POSTFIELDS).
I was told that curl_easy_perform() sends and receives the responses. Now
the http-post example doesn't highlight how to verify whether the correct
response is sent back by the webservice. i don't want to write the responses
in file, i just want to print them on my console. How to achieve that?

my code is:

#include <stdio.h>
#include <curl/curl.h>

int main(void)
{
  CURL *curl;
  CURLcode res;

const char *temp = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<S:Envelope xmlns:S=\"http://schemas.xmlsoap.org/soap/envelope/\"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"xmlns:tns=\"http://ThermodynamicProperties/\"><S:Body>
<tns:getSpeciesInformation> <speciesSymbol>CO2</speciesSymbol>
<phase>GAS</phase> </tns:getSpeciesInformation> </S:Body>
</S:Envelope>";

printf("%s",temp);

curl = curl_easy_init();
  if(curl) {
    /* First set the URL that is about to receive our POST. This URL can
       just as well be a https:// URL if that is what should receive the
       data. */
    curl_easy_setopt(curl, CURLOPT_URL,
"http://thermo.sdsu.edu/servlet/ThermodynamicProperties/ThermodynamicPropertiesService");
    /* Now specify the POST data */
    curl_easy_setopt(curl, CURLOPT_POSTFIELDS, temp);

    printf("OK \n");

    /* Perform the request, res will get the return code */
    res = curl_easy_perform(curl);

      /* always cleanup */
    curl_easy_cleanup(curl);
  }
  return 0;
}

I just want to achieve the basic send and receive post responses.
Thanks in advance.

-- 
*Cheers*
*Abhishek Kalapatapu*

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-09-13