开发者

How to check the SOAP Response using libcurl

I am sending a SOAP request to a web service and I want to check what response I have received. How to achieve this?

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:getSpeciesInforma开发者_JS百科tion> </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;
}

Right now the response I am getting is:

Sending request. Reading response. Received 123 bytes.

How to print what I am receiving??


You can use a callback function which gets passed the response. You can find an example here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜