1、gsoap是什么?
The gSOAP toolkit is an open source C and C++ software development toolkit forSOAP/XML Web services and generic (non-SOAP)C/C++ XML data bindings. The toolkit analyzes WSDLs and XML schemas (separately or as a combined set) and maps the XML schema types and the SOAP messaging protocols to easy-to-use and efficient C and C++ code. It also supports exposing (legacy) C and C++ applications as SOAP/XML Web services by auto-generating XML serialization code and WSDL specifications. Or you can simply use it toautomatically convert XML to/from C and C++ data. The toolkit supports options to generate pure ANSI C or C++ with or without STL.
这是gsoap介绍的原文,简单来说,gsoap就是一个工具,这个工具能够做的事情就是自动从WSDL和XML文档生成C/C++代码,或者是逆向。这就是我所理解的gsoap。
记录下:
gSOAP编译工具提供了一个SOAP/XML 关于C/C++ 语言的实现,从而让C/C++语言开发web服务或客户端程序的工作变得轻松了很多。绝大多数的C++web服务工具包提供一组API函数类库来处理特定的SOAP数据结构,这样就使得用户必须改变程序结构来适应相关的类库。与之相反,gSOAP利用编译器技术提供了一组透明化的SOAP API,并将与开发无关的SOAP实现细节相关的内容对用户隐藏起来。
[-v] [-w] [-x] [-y] [-z] [-o outfile.h] infile.wsdl infile.xsd http://www... ...
type map文件用于指定SOAP/XML中的类型与C/C++之间的转换规则,比如在wsmap.dat里写。
关于typemap.dat,在下载的gsoap中是有另外一个,叫:WS-typemap.dat。 如果有多个wsdl文档,建议使用这个。
wsdl2h针对多个文档: wsdl2h.exe -sc -t WS-typemap.dat -o quote.h a.wsdl b.wsdl c.wsdl
b、soapcpp2的使用
命令: soapcpp2 【】 头文件名 【-I】 import路径
例 : soapcpp2 -L -c quote.h -I E:\gsoap-2.8\gsoap\import
soapcpp2常用选项
[-v] [-w] [-x] [-y] [-z] [-o outfile.h] infile.wsdl infile.xsd http://www... ...
-c generate C source code
-d use DOM to populate xs:any and xsd:anyType elements
-e don't qualify enum names
-f generate flat C++ class hierarchy
-g generate global top-level element declarations
-h display help info
-Ipath use path to find files
-j don't generate SOAP_ENV__Header and SOAP_ENV__Detail definitions
-l include license information in output
-m use xsd.h module to import primitive types
-nname use name as the base namespace prefix instead of 'ns'
-Nname use name as the base namespace prefix for service namespaces
-ofile output to file
-p create polymorphic types with C++ inheritance with base xsd__anyType
-qname use name for the C++ namespace for all service declarations
-rhost:port /* ??? 暂没理解 */
connect via proxy host and port
-s don't generate STL code (no std::string and no std::vector)
-tfile use type map file instead of the default file typemap.dat
-u don't generate unions
-v verbose output
-w always wrap response parameters in a response struct (<=1.1.4 behavior)
-x don't generate _XML any/anyAttribute extensibility elements
-y generate typedef synonyms for structs and enums
-z generate pointer-based arrays for backward compatibility < gSOAP 2.7.6e
-2 generate SOAP 1.2 bindings
-C generate client-side code only
-S generate server-side code only
-L don't generate soapClientLib/soapServerLib
-a use value of SOAPAction HTTP header to dispatch method at server side
-c generate C source code
-dpath use path to save files
-e generate SOAP RPC encoding style bindings
-h display help info
-i generate service proxies and objects inherited from soap struct
-Ipath use path(s) for #import
-l generate linkable modules (experimental)
-m generate Matlab(tm) code for MEX compiler
-n use service name to rename service functions and namespace table
-pname save files with new prefix name instead of 'soap'
-s generate deserialization code with strict XML validation checks
-t generate code for fully xsi:type typed SOAP/XML messaging
-v display version info
-w don't generate WSDL and schema files
-x don't generate sample XML message files
infile header file to parse (or stdin)