1)使用手册:见http://gsoap2.sourceforge.net/
2)gsoap 支持自带日志打印、系列化反系列化、加密封装,跨平台(win、linux、unix、mac),是个值得学习且很好的工具。认真看下,
大约1、2天就能学会使用。记得我在用ibm web swhere mq自带的纯c工具包的开发时候真是个费劲啊。相见恨晚啊!
extern "C" int __cdecl EXPORT TestWebServiceIF(char* returnstr)
{
struct soap Test_soap;
//初始化gSoap运行时环境变量,只需初始化一次
soap_init(&Test_soap);
int result = -1;
//远程web服务的endpoint URL
const char* server="http://192.168.1.100:5150";
//声明一些请求、返回类型
_ns1__modifyCustDoc* req = new _ns1__modifyCustDoc();
req->requestXml = "now i will write to you!";
_ns1__modifyCustDocResponse* resp = new _ns1__modifyCustDocResponse();
//调用根据远程服务产生函数的接口
result = soap_call___ns1__modifyCustDoc(&Test_soap, server, "", req, resp);
if(Test_soap.error)
{
//在stderr流中打印soap的错误信息
char logtemp[LOG_MAX_SIZE];
memset(logtemp,'\0',LOG_MAX_SIZE);
soap_sprint_fault(&Test_soap,logtemp,LOG_MAX_SIZE);
WriteToLogFile(string(logtemp),true);
result = Test_soap.error;
}
//soap::~soap()
soap_destroy(&Test_soap);// 删除反序列化类的实例,仅用于c++
soap_end(&Test_soap); // 清空已经并行化的数据
soap_done(&Test_soap); // 与gSOAP 环境相分离,关闭连接
if (result != 0)
{
//printf("soap error ,errcode = %d\n", result);
}
else
{
WriteToLogFile("soap if successful !",true);
}
delete req;
delete resp;
CopyStringAndAddEndFlag(returnstr,"正在测试中,请检查接口文档!");
return result;
}