gSOAP編譯工具提供了一個SOAP/XML 關于C/C++ 語言的實現,從而讓C/C++語言開發web服務或客戶端程序的工作變得輕松了很多。絕大多數的C++web服務工具包提供一組API函數類庫來處理特定的SOAP數據結構,這樣就使得用戶必須改變程序結構來適應相關的類庫。與之相反,gSOAP利用編譯器技術提供了一組透明化的SOAP API,并將與開發無關的SOAP實現細節相關的內容對用戶隱藏起來。gSOAP的編譯器能夠自動的將用戶定義的本地化的C或C++數據類型轉變為符合XML語法的數據結構,反之亦然。這樣,只用一組簡單的API就將用戶從SOAP細節實現工作中解脫了出來,可以專注與應用程序邏輯的實現工作了。gSOAP編譯器可以集成C/C++和Fortran代碼(通過一個Fortran到C的接口),嵌入式系統,其他SOAP程序提供的實時軟件的資源和信息;可以跨越多個操作系統,語言環境以及在防火墻后的不同組織。
gSOAP使編寫web服務的工作最小化了。gSOAP編譯器生成SOAP的代碼來序列化或反序列化C/C++的數據結構。gSOAP包含一個WSDL生成器,用它來為你的web服務生成web服務的解釋。gSOAP的解釋器及導入器可以使用戶不需要分析web服務的細節就可以實現一個客戶端或服務端程序。下面是gSOAP的一些特點:
l gSOAP編譯器可以根據用戶定義的C和C++數據結構自動生成符合SOAP的實例化代碼。
l gSOAP支持WSDL 1.1, SOAP 1.1, SOAP 1.2, SOAP RPC 編碼方式以及 literal/document 方式.
l gSOAP是少數完全支持SOAP1.1 RPC編碼功能的工具包,包括多維數組及動態類型。比如,一個包含一個基類參數的遠程方法可以接收客戶端傳來的子類實例。子類實例通過動態綁定技術來保持一致性。
l gSOAP 支持 MIME (SwA) 和 DIME 附件包。
l gSOAP是唯一支持DIME附件傳輸的工具包。它允許你在保證XML可用性的同時能夠以最快的方式(流方式)傳遞近乎無大小限制的二進制數據。
l gSOAP 支持 SOAP-over-UDP。
l gSOAP 支持 IPv4 and IPv6.
l gSOAP 支持 Zlib deflate and gzip compression (for HTTP, TCP/IP, and XML file storage)。
l gSOAP 支持 SSL (HTTPS)。
l gSOAP 支持 HTTP/1.0, HTTP/1.1 保持連接, 分塊傳輸及基本驗證。
l gSOAP 支持 SOAP 單向消息。
l gSOAP 包含一個 WSDL 生成器,便于web服務的發布。
l gSOAP 包含一個WSDL解析器 (將WSDL轉換為gSOAP頭文件),可以自動化用戶客戶端及服務端的開發。
l 生成可以單獨運行的web服務及客戶端程序。
l 因為只需要很少內存空間,所以可以運行在類似Palm OS, Symbian, Pocket PC的小型設備中。
l 適用于以C或C++開發的web服務中。
l 跨平臺:Windows, Unix, Linux, Mac OS X, Pocket PC, Palm OS, Symbian等。
l 支持序列化程序中的本地化C/C++數據結構。
l 可以使用輸入和輸出緩沖區來提高效率,但是不用完全消息緩沖來確定HTTP消息的長度。取而代之的是一個三相序列化方法。這樣,像64位編碼的圖像就可以在小內存設備(如PDA)中以DIME附件或其他方式傳輸。
l 支持C++單繼承,動態綁定,重載,指針結構(列表、樹、圖、循環圖,定長數組,動態數組,枚舉,64位2進制編碼及16進制編碼)。
l 不需要重寫現有的C/C++應用。但是,不能用unions,指針和空指針來作為遠程方法調用參數的數據結構中元素。
l 三相編組:1)分析指針,引用,循環數據結構;2)確定HTTP消息長度;3)將數據序列化位SOAP1.1編碼方式或用戶定義的數據編碼方式。
l 雙相編組:1)SOAP解釋及編碼;2)分解“forward”指針(例如:分解SOAP中的href屬性)。
l 完整可定制的SOAP錯誤處理機制。
l 可定制的SOAP消息頭處理機制,可以用來保持狀態信息
gsoap通常帶有兩個工具: wsdl2h 和 soapcpp2。 wsdl2h主要是用來生成頭文件的,而soapcpp2主要是利用wsdl2h生成的頭文件來生成C文件或C++文件。以下是README.txt中示例:
wsdl2h.exe -o TestServices.h http://192.168.20.242/ClientUpdateWebService.asmx?WSDL
soapcpp2 TestServices.h
出現如下錯誤:Critical error: #import: Cannot open file "stlvector.h" for reading.你需要在gsoap\import下把這個文件拷貝過來。
** Copyright (C) 2000-2011 Robert van Engelen, Genivia Inc.
** All Rights Reserved. This product is provided "as is", without any warranty.
** The wsdl2h tool is released under one of the following two licenses:
** GPL or the commercial license by Genivia Inc. Use option -l for details.
Usage: wsdl2h [-a] [-c] [-d] [-e] [-f] [-g] [-h] [-I path] [-i] [-j] [-k] [-l] [
-m] [-n name] [-N name] [-p|-P] [-q name] [-r proxyhost[:port[:uid:pwd]]] [-s] [
-t typemapfile] [-u] [-v] [-w] [-W] [-x] [-y] [-z#] [-_] [-o outfile.h] infile.w
sdl infile.xsd http://www

-a generate indexed struct names for local elements with anonymous types
-c generate C source code
-d use DOM to populate xs:any, xs:anyType, and xs:anyAttribute
-e don't qualify enum names
-f generate flat C++ class hierarchy
-g generate global top-level element declarations
-h display help info
-i don't import (advanced option)
-Ipath use path to find files
-j don't generate SOAP_ENV__Header and SOAP_ENV__Detail definitions
-k don't generate SOAP_ENV__Header mustUnderstand qualifiers
-l display license information
-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 from base xsd__anyType
-P don't create polymorphic types with C++ inheritance from xsd__anyType
-qname use name for the C++ namespace of all declarations
-rhost[:port[:uid:pwd]]
connect via proxy host, port, and proxy credentials
-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)
-W suppress warnings
-x don't generate _XML any/anyAttribute extensibility elements
-y generate typedef synonyms for structs and enums
-z1 compatibility with 2.7.6e: generate pointer-based arrays
-z2 compatibility with 2.7.15: qualify element/attribute referenced members
-_ don't generate _USCORE (replace with UNICODE _x005f)
list of input sources (if none: use stdin) -h] [-i] [-I path;path;
] [-k] [-l] [-m] [-n] [-p name] [-s] [-t] [-u] [-v] [-w] [-x] [-y] [infile]
-1 generate SOAP 1.1 bindings
-2 generate SOAP 1.2 bindings
-C generate client-side code only
-S generate server-side code only
-T generate server auto-test code
-L don't generate soapClientLib/soapServerLib
-a use SOAPAction HTTP/WSA header to invoke server-side operations
-b serialize byte arrays char[N] as string
-c generate C source code
-dpath use path to save files
-e generate SOAP RPC encoding style bindings
-fN file split of N XML serializer implementations per file (N>=10)
-h display help info
-Ipath use path(s) for #import
-i generate C++ service proxies and objects inherited from soap struct
-j generate C++ service proxies and objects that share a soap struct
-k generate data structure walkers (experimental)
-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'
-qname use name as the C++ namespace of all declarations
-s generate deserialization code with strict XML validation checks
-t generate code for fully xsi:type typed SOAP/XML messaging
-u uncomment comments in WSDL/schema output by suppressing XML comments
-v display version info
-w don't generate WSDL and schema files
-x don't generate sample XML message files
-y include C/C++ type access information in sample XML messages
其他相關鏈接: http://m.shnenglu.com/woaidongmao/archive/2008/05/28/51400.html


