gpt4 book ai didi

c - 如何使用 libcurl 检查 SOAP 响应

转载 作者:行者123 更新时间:2023-11-30 18:04:46 26 4
gpt4 key购买 nike

我正在向 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 字节。

如何打印我收到的内容?

最佳答案

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

关于c - 如何使用 libcurl 检查 SOAP 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7395279/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com