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)