gSoap一点小经验总结

1、客户端支持多平台编译

1)wsdl2h -n别名 -N服务命名空间 -o xxx.h xxx.wsdl

eg: wsdl2h -nuseraddns -NUserAddWS -o UserAddWebService.h userAddWebServiece.wsdl

      wsdl2h -nuserLoginns -NUserLoginWS -o UserLoginWebService.h userLoginWebServiece.wsdl

2)将“UserAddWebService.h ”与“UserLoginWebService.h”整合成一个文件MSWS.h——其中注意协议版本低的放在前面

3)soapcpp2 -i -I "d:\gsoap-2.8\gsoap\import" MSWS.h

4)soapcpp2 -I "d:\gsoap-2.8\gsoap\import" MSWS.h

2、错误“org.apache.cxf.binding.soap.SoapFault: A SOAP 1.2 message is not valid when sent to a SOAP 1.1 only endpoint.”

此错误是指服务器协议版本与客户端的协议版本不统一,服务器端协议版本是1.1,而客户端则是1.2;

修改方法:

将    {"SOAP-ENV", "http://www.w3.org/2003/05/soap-envelope", "http://schemas.xmlsoap.org/soap/envelope/", NULL},
{"SOAP-ENC", "http://www.w3.org/2003/05/soap-encoding", "http://schemas.xmlsoap.org/soap/encoding/", NULL},
{"xsi", "http://www.w3.org/2001/XMLSchema-instance", "http://www.w3.org/*/XMLSchema-instance", NULL},
{"xsd", "http://www.w3.org/2001/XMLSchema", "http://www.w3.org/*/XMLSchema", NULL},

改为
        {"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", NULL, NULL},
        {"SOAP-ENC",  "http://schemas.xmlsoap.org/soap/encoding/",NULL, NULL},
        {"xsi", "http://www.w3.org/2001/XMLSchema-instance", NULL, NULL},
        {"xsd", "http://www.w3.org/2001/XMLSchema", NULL, NULL},
 3、中文乱码

soap_set_mode(&soap,SOAP_C_UTFSTRING);

客户端字符串转换成toUtf8()即可。

猜你喜欢

转载自blog.csdn.net/zhuzi2129/article/details/78654531