51 lines
1.9 KiB
Plaintext
51 lines
1.9 KiB
Plaintext
用法:
|
||
wsdl2h -o 头文件名 WSDL文件名或URLwsdl2h常用选项
|
||
-o 文件名,指定输出头文件
|
||
-n 名空间前缀 代替默认的ns
|
||
-c 产生纯C代码,否则是C++代码
|
||
-s 不要使用STL代码
|
||
-t 文件名,指定type map文件,默认为typemap.dat
|
||
-e 禁止为enum成员加上名空间前缀
|
||
type map文件用于指定SOAP/XML中的类型与C/C++之间的转换规则,比如在wsmap.dat里写
|
||
xsd__string = | std::wstring | wchar_t*那么SOAP/XML中的string将转换成std::wstring或wchar_t*,这样能更好地支持中文。
|
||
例:
|
||
wsdl2h -o ayandy.h \
|
||
-n ay -t wsmap.dat \
|
||
http://www.ayandy.com/Service.asmx?WSDL
|
||
|
||
|
||
综上所述
|
||
如果编写服务器端,项目里应该加入soapServerLib.c,代码里包含头文件soapH.h
|
||
如果编写客户端,项目里应该加入soapClientLib.c,代码里包含头文件SoapH.h(或xxxxProxy.h)
|
||
当然,还要加入gsoap库里的stdsoap2.cpp文件(如果是写C代码,则加入stdsoap2.c)
|
||
如果看到soapcpp2提示:”Critical error: #import: Cannot open file "stlvector.h" for reading.“, 那是因为我们的头文件使用了STL(wsdl2h 没用-s选项),这时要使用-I选项指定gSOAP的 import文件路径,这个路径是"$gsoap\gsoap\import":
|
||
soapcpp2 ayandy.h -I D:\gsoap-2.7\gsoap\importsoapcpp2常用选项
|
||
-C 仅生成客户端代码
|
||
-S 仅生成服务器端代码
|
||
-L 不要产生soapClientLib.c和soapServerLib.c文件
|
||
-c 产生纯C代码,否则是C++代码(与头文件有关)
|
||
-I 指定import路径(见上文)
|
||
-x 不要产生XML示例文件
|
||
-i 生成C++包装,客户端为xxxxProxy.h(.cpp),服务器端为xxxxService.h(.cpp)。
|
||
|
||
|
||
|
||
写一个wsmap.dat文件,里面写上:xsd__string = | std::wstring | std::wstring*
|
||
|
||
从samples\components\cpp2拷贝env.h,fault.h,header.h到\bin下。
|
||
|
||
soapcpp2 -CS -penv env.h //生成公用类
|
||
|
||
wsdl2h -s -qMobsetApi -o MobsetApi.h -t wsmap.dat MobsetApi.wsdl
|
||
soapcpp2 -i -n -pMobsetApi MobsetApi.h
|
||
|
||
|
||
#include ".\MobsetApi\H.nsmap"
|
||
#include ".\MobsetApi\MobsetApi.nsmap"
|
||
#include ".\MobsetApi\MobsetApiMobsetMmsSoapProxy.h"
|
||
#include ".\MobsetApi\MobsetApiMobsetMmsSoapService.h"
|
||
|
||
|
||
stdsoap2.*,envC.*需要加入工程
|
||
|
||
对于Server,生成新类,继承原来的虚函数,并且生成一个原来类的虚函数 |