近期工程需要用到,编写了一个简单的例子,遇到了点问题,记录下来并分享让以后的人可以少走弯路
一、服务端
1.首先要下载gsoap开发包http://sourceforge.net/projects/gsoap2/
2.解压并编写自己需要执行的函数头文件mySoap.h
//gsoap ns service name: dataStream
//gsoap ns service namespace: http://localhost/dataStream.wsdl
//gsoap ns service location: http://localhost
//gsoap ns service executable: dataStream.cgi
//gsoap ns service encoding: encoded
//gsoap ns schema namespace: urn:dataStream
int ns__dataStream(std::wstring param_in, std::wstring& param_out);
3.使用soapcpp2.exe导出需要的源文件
在下载源码包的gsoap2-8/gsoap/bin/win32目录下有soapcpp2.exe,打开控制台应用程序切换到gsoap2-8/gsoap/bin/win32目录下执行soapcpp2.exe mySsoap.h生成以下几个文件
dataStream.nsmap
soapC.cpp:服务器和客户端都需要
soapClient.cpp:客户端用到
soapClientLib.cpp
soapH.h
soapServer.cpp:服务器用到
soapServerLib.cpp
soapStub.h
dataStream.dataStream.req.xml
dataStream.dataStream.res.xml
ns.xsd
4.新建服务器工程,添加3生成的部分源文件和库中的2个文件(stdsoap2.h、stdsoap2.cpp,stdsoap2.h 、stdsoap2.cpp在源码包的gsoap-2.8/gsoap)到工程
服务器添加mySsoap.h、