用c++写调用webservise的代码
时间: 2023-03-31 14:01:22 浏览: 81
可以使用 gSOAP 库来调用 WebService。以下是一个简单的示例代码:
#include "soapH.h"
#include "calc.nsmap"
int main()
{
struct soap soap;
soap_init(&soap);
double a = 2., b = 3., result;
if (soap_call_ns1__add(&soap, "http://localhost:808/calc", "", a, b, &result) == SOAP_OK)
{
printf("The result of %f + %f is %f\n", a, b, result);
}
else
{
soap_print_fault(&soap, stderr);
}
soap_destroy(&soap);
soap_end(&soap);
soap_done(&soap);
return ;
}
其中,soap_call_ns1__add 是调用 WebService 的函数,"http://localhost:808/calc" 是 WebService 的地址,a 和 b 是要相加的两个数,result 是返回的结果。