web service gsoap 小记
参考 http://www.cs.fsu.edu/~engelen/soap.html
1. web service client application
> wsdl2h -s -o MyHead.h http://www.genivia.com/calc.wsdl
-s 不用 STL
> soapcpp2 -i -C MyHead.h
Option -i (and alternatively option -j) indicates that we want C++ proxy and server objects that include the client (and server) code, -C indicates client-side only
soapcpp2 generates both client and server stubs and skeletons by default
这两步过程中可能会出错,要把必要的文件加上。 soap12.h/stdsoap2.h/stdsoap2.cpp
然后,We use the generated soapcalcProxy class and calc.nsmap XML namespace mapping table to access the Web service. The soapcalcProxy class is a proxy to invoke the service:
1 #include "soapWebService1SoapProxy.h" // 自动生成的头文件 注:不用MyHead.h 2 #include "WebService1Soap.nsmap" 3 4 int main() 5 { 6 WebService1SoapProxy service; 7 _tempuri__GetSum a; 8 _tempuri__GetSumResponse result; 9 //a.soap = soap_new(); 10 a.a = 1; 11 a.b = 5; 12 //result.soap = soap_new(); 13 14 if (service.GetSum(&a, &result) == SOAP_OK) 15 std::cout << "the num of 1 and 5 is " << result.GetSumResult << std::endl; 16 else 17 service.soap_stream_fault(std::cerr); 18 service.destroy(); 19 20 getchar(); 21 return 0; 22 }
编译
如果遇到 stdsoap2.obj : error LNK2001: 无法解析的外部符号_namespaces
参考http://blog.163.com/lyz_sea/blog/static/115586707201182432412677
在 stdsoap2.h,添加
#ifndef WITH_NONAMESPACES
#define WITH_NONAMESPACES
#endif
2. Develop a Web Service
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。