【问题标题】:How to check the SOAP Response using libcurl如何使用 libcurl 检查 SOAP 响应
【发布时间】:2011-09-12 23:39:11
【问题描述】:

我正在向 Web 服务发送一个 SOAP 请求,并且我想检查我收到了什么响应。如何做到这一点?

我的代码是:

#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;
}

现在我得到的回应是:

发送请求。 阅读回复。 收到 123 个字节。

如何打印我收到的内容??

【问题讨论】:

    标签: c soap libcurl


    【解决方案1】:

    您可以使用一个回调函数来传递响应。你可以找到example here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-08
      • 2015-04-03
      • 2016-12-09
      • 2011-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多