GSOAP
   HOME

TheInfoList



OR:

gSOAP is a C and C++ software development toolkit for
SOAP Soap is a salt of a fatty acid used in a variety of cleansing and lubricating products. In a domestic setting, soaps are surfactants usually used for washing, bathing, and other types of housekeeping. In industrial settings, soaps are use ...
/
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
web services and generic
XML data binding XML data binding refers to a means of representing information in an XML document as a business object in computer memory. This allows applications to access the data in the XML from the object rather than using the DOM or SAX to retrieve the da ...
s. Given a set of C/C++ type declarations, the compiler-based gSOAP tools generate serialization routines in source code for efficient XML serialization of the specified C and C++ data structures. Serialization takes
zero-copy "Zero-copy" describes computer operations in which the CPU does not perform the task of copying data from one memory area to another or in which unnecessary data copies are avoided. This is frequently used to save CPU cycles and memory bandwi ...
overhead.


History

The gSOAP toolkit started as a research project at the Florida State University by professor Robert van Engelen in 1999. The project introduced new methods for highly-efficient XML parsing (pull parsing) and serialization of C/C++ data directly in
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable ...
and later also in
SOAP Soap is a salt of a fatty acid used in a variety of cleansing and lubricating products. In a domestic setting, soaps are surfactants usually used for washing, bathing, and other types of housekeeping. In industrial settings, soaps are use ...
. The project succeeded at defining
type-safe In computer science, type safety and type soundness are the extent to which a programming language discourages or prevents type errors. Type safety is sometimes alternatively considered to be a property of facilities of a computer language; that is ...
data bindings between
XML Schema An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constra ...
types and a wide variety of C/C++ data types. The toolkit uses
automatic programming In computer science, the term automatic programming identifies a type of computer programming in which some mechanism generates a computer program to allow human programmers to write the code at a higher abstraction level. There has been little ...
to simplify the development and invocation of Web services using efficient auto-generated XML serializers to send and receive C/C++ data directly. A domain-specific compiler-based tool generates source code that efficiently converts native C/C++ data structures to XML and back. The toolkit was further developed to support the SOAP web services messaging protocol, introduced at around the same time, therefore the name "gSOAP" (generic XML and SOAP) and to use the approach for scientific data exchange. Further development and maintenance of the software took place under ownership of Genivia Inc. This includes the addition of new
WSDL The Web Services Description Language (WSDL ) is an XML-based interface description language that is used for describing the functionality offered by a web service. The acronym is also used for any specific WSDL description of a web service (also ...
and
XML Schema An XML schema is a description of a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntactical constraints imposed by XML itself. These constra ...
processing capabilities as well as the addition of many WS-* web services protocol capabilities such as WS-Security optimizations,
XML-RPC XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.Simon St. Laurent, Joe Johnston, Edd Dumbill. (June 2001) ''Programming Web Services with XML-RPC.'' O'Reilly. First Edit ...
messaging, support for the JSON data format, plugin modules to integrate gSOAP in Apache and IIS web servers, and third-party plugins such as for Grid Services. The gSOAP toolkit is written in portable C/C++ and uses a form of
bootstrapping In general, bootstrapping usually refers to a self-starting process that is supposed to continue or grow without external input. Etymology Tall boots may have a tab, loop or handle at the top known as a bootstrap, allowing one to use fingers ...
by generating its own code to implement a converter to translate WSDL/XSD specifications to C/C++ source code for WSDL/XSD meta-data bindings. The gSOAP software is licensed under the GPLv2 open source license and commercial-use source code licenses. The gSOAP software is widely used in industrial projects and mission-critical infrastructures.


XML Web Service Operations by Example

An example web service operation in C for retrieving the lodging rate of a hotel given a number of guests can be declared in annotated form as //gsoap ns service namespace: tempuri //gsoap ns service style: document //gsoap ns service encoding: literal int ns__get_rate(char* hotel, int guests, float *rate); The last parameter of the function is always the service return value, which can be denoted as void for one-way operations and should be a struct/class to bundle multiple service return parameters. The function's int return value is used for error diagnostics. A service invocation in C using the auto-generated soap_call_ns__get_rate function is executed as follows: const char *URL = "http://www.example.com/hotels"; const char *action = NULL; struct soap *ctx = soap_new(); // new context float rate; int err = soap_call_ns__get_rate(ctx, URL, action, "Happy Inn", 2, &rate); if (err

SOAP_OK && rate < 100.00) lets_go(); soap_end(ctx); // deallocate deserialized data soap_free(ctx); // deallocate context
To facilitate web services implementations for legacy C and C++ systems, the prefix qualification of identifier names in C/C++ can be omitted or can be replaced by colon notation, for example ns:get_rate rather than ns__get_rate. The punctuation is removed in the auto-generated source code that is used in project builds. A service invocation in C++ using the auto-generated Proxy class is executed as follows (using the Proxy's default endpoint URL and SOAP action values): Proxy proxy; float rate; int err = proxy.get_rate("Happy Inn", 2, &rate); if (err

SOAP_OK && rate < 100.00) lets_go(); proxy.destroy(); // deallocate deserialized data
By using annotations and identifier naming conventions, i.e. qualification with the prefix ns__ for the function ns__get_rate and by declaring properties of the ns namespace using the //gsoap directives in the example, a binding is established to web service operations. The auto-generated Web Services Description Language (WSDL) document declares a request message, a response message, and the get-rate operation portType interface and SOAP binding for the ns__get_rate function as follows: ... where the request and responses messages of the operation refer to XML elements that are defined in the types section of the WSDL as follows: Likewise, client and server C/C++ source code can be auto-generated from a set of WSDLs and XML schemas. Services must be completed by defining the appropriate service operations. For example, the auto-generated C++ service class for this WSDL must be completed by defining the get_rate method as follows: int Service::get_rate(char *hotel, int guests, float *rate) There are no restrictions on the type of the operation parameters that can be marshaled in XML for web service messaging, except that certain type declaration conventions and annotations should be followed to establish a data binding.


XML Data Binding by Example

To establish an XML data binding with C/C++ data types, gSOAP uses three basic forms of source code annotation: directives, identifier naming conventions, and punctuation. A fully annotated structure declaration in C for a hierarchical employee record may appear as //gsoap ns schema namespace: tempuri //gsoap ns schema form: qualified struct ns__employee_record ; where the following annotations and conventions are used: * namespace qualification of types and members by identifier naming conventions: ns__employee_record, xml__lang * attributes for members: @char*, @int * default values for members: xml__lang = "en", ID = 9999 * occurrence constraints in the form of ''minOccurs'':''maxOccurs'' for XML validation: full_name 1:1, size 0:12 * dynamic arrays of element sequences consist of a pair of a special size field and an array pointer member: $int size; struct ns__employee_record *manages The gSOAP tools convert C/C++ data types to/from XML schema data types. Since C does not support namespaces and struct/class member names cannot be namespace-qualified in C++, the use of identifier naming conventions in gSOAP allow for binding this structure and its members to an XML schema complexType that is auto-generated as follows: Furthermore, unions in a struct/class that are annotated with a special selector field for union member selection are mapped to/from schema choice particles, STL containers are mapped to/from sequence particles, enumerations are mapped to/from XML schema simpleType enumerations, and standard C/C++ primitive types are mapped to/from XSD types. For conversion of XSD schema to C/C++ data types, the actual mapping is configurable in gSOAP with a type mapping file. An instance of the example hierarchical employee structure is serialized in XML as a tree by default, for example Jane Doe John Doe Bob Oz Alice Oz When the SOAP encoding style is enabled, the XML serialization in gSOAP respects co-referenced objects and cyclic data structures as per SOAP encoding rules resulting in XML with ''id-ref'' edges. The auto-generated XML data binding includes read and write operations to/from a file, string or stream. For example, an ns__employee_record object has read and write operations: int soap_read_ns__employee_record(struct soap*, ns__employee_record*); int soap_write_ns__employee_record(struct soap*, const ns__employee_record*); To read an employee record from an XML file: struct soap *ctx = soap_new(); ctx->recvfd = open("employee.xml", O_RDONLY); if (ctx->recvfd) soap_end(ctx); soap_destroy(ctx); // also deletes employee data soap_free(ctx); Parsed XML is internally validated against the data bindings' constraints.


XML REST API

Application data can be sent and received to/from a REST XML service. The XML data binding provides REST XML API calls. For example, given the ns__employee_record XML data binding of the previous section, the following GET, PUT and POST operations are auto-generated: int soap_GET_ns__employee_record(struct soap*, const char *URL, ns__employee_record*); int soap_PUT_ns__employee_record(struct soap*, const char *URL, const ns__employee_record*); int soap_POST_send_ns__employee_record(struct soap*, const char *URL, const ns__employee_record*); int soap_POST_recv_ns__employee_record(struct soap*, ns__employee_record*); The POST functions should be called together, first a POST_send to transmit XML data to the endpoint URL followed by a POST_recv to accept the response data (may be of a different type). Received XML is internally validated against the data bindings' constraints.


Features

*
XML data binding XML data binding refers to a means of representing information in an XML document as a business object in computer memory. This allows applications to access the data in the XML from the object rather than using the DOM or SAX to retrieve the da ...
for C and C++ based on
automatic programming In computer science, the term automatic programming identifies a type of computer programming in which some mechanism generates a computer program to allow human programmers to write the code at a higher abstraction level. There has been little ...
with source-to-source code generation * Customizable client/server source code auto-generation in ANSI C and ISO C++ * Integrated high-speed, schema-specific XML pull parsing with
XML validation XML validation is the process of checking a document written in XML (eXtensible Markup Language) to confirm that it is both well-formed and also "valid" in that it follows a defined structure. A well-formed document follows the basic syntactic rul ...
*
Web Services Description Language The Web Services Description Language (WSDL ) is an XML-based interface description language that is used for describing the functionality offered by a web service. The acronym is also used for any specific WSDL description of a web service (als ...
(WSDL) 1.1 and 2.0 * Web services
SOAP Soap is a salt of a fatty acid used in a variety of cleansing and lubricating products. In a domestic setting, soaps are surfactants usually used for washing, bathing, and other types of housekeeping. In industrial settings, soaps are use ...
1.1 and 1.2 * Streaming Message Transmission Optimization Mechanism (MTOM) and DIME/MIME attachments * Representational state transfer (REST) HTTP(S) 1.0/1.1 * Verified
WS-I Basic Profile {{Short description, Interoperability guidance for core web services specifications The WS-I Basic Profile (official abbreviation is BP), a specification from the Web Services Interoperability industry consortium (WS-I), provides interoperability gu ...
1.0a, 1.1, and 1.2 compliant * Verifie
W3C schema patterns for data binding
full test pattern coverage *
XML-RPC XML-RPC is a remote procedure call (RPC) protocol which uses XML to encode its calls and HTTP as a transport mechanism.Simon St. Laurent, Joe Johnston, Edd Dumbill. (June 2001) ''Programming Web Services with XML-RPC.'' O'Reilly. First Edit ...
for C and C++ * JSON for C and C++ * RSS 0.91, 0.92, 2.0 *
WS-Security Web Services Security (WS-Security, WSS) is an extension to SOAP to apply security to Web services. It is a member of the Web service specifications and was published by OASIS. The protocol specifies how integrity and confidentiality can be enfo ...
* WS-Policy 1.2, 1.5 and
WS-SecurityPolicy WS-SecurityPolicy is a web services specification, created by IBM and 12 co-authors, that has become an OASIS standard as of version 1.2. It extends the fundamental security protocols specified by the WS-Security, WS-Trust and WS-SecureConversat ...
1.2 *
WS-Addressing Web Services Addressing (WS-Addressing) is a specification of transport-neutral mechanism that allows web services to communicate addressing information. It essentially consists of two parts: a structure for communicating a reference to a Web ser ...
2003/03, 2004/03, 2005/03 *
WS-ReliableMessaging WS-ReliableMessaging describes a protocol that allows SOAP messages to be reliably delivered between distributed applications in the presence of software component, system, or network failures. The original specification was written by BEA Syste ...
1.0 and 1.1 *
WS-Discovery Web Services Dynamic Discovery (WS-Discovery) is a technical specification that defines a multicast discovery protocol to locate services on a local network. It operates over TCP and UDP port 3702 and uses IP multicast address or . As the name s ...
1.0/1.1 * SOAP-over-UDP *
Universal Description Discovery and Integration Web Services Discovery provides access to software systems over the Internet using standard protocols. In the most basic scenario there is a ''Web Service Provider'' that publishes a service and a ''Web Service Consumer'' that uses this service. ...
(UDDI) v2 API * HTTP basic and digest authentication, NTLM authentication, proxy authentication * IPv4 and IPv6 with SSL/TLS with SSL session caching (based on OpenSSL or
GNUTLS GnuTLS (, the GNU Transport Layer Security Library) is a free software implementation of the TLS, SSL and DTLS protocols. It offers an application programming interface (API) for applications to enable secure communication over the network trans ...
) * XML compression with
gzip gzip is a file format and a software application used for file compression and decompression. The program was created by Jean-loup Gailly and Mark Adler as a free software replacement for the compress program used in early Unix systems, and i ...
* Apache 1.x and 2.0 modules, IIS
ISAPI The Internet Server Application Programming Interface (ISAPI) is an N-tier API of Internet Information Services (IIS), Microsoft's collection of Windows-based web server services. The most prominent application of IIS and ISAPI is Microsoft's we ...
and WinInet modules, CGI and FastCGI * Stand-alone web server support (multithreaded, pooling) * Integrated memory management with deallocation and leak detection * Architecture with plug-ins for additional capabilities * Internationalization/localization support (UTF8, UCS4, MB encodings, etc.) * Platform neutral, supports small devices (Symbian, VxWorks, Android, iPhone)


References

{{Reflist


See also


Getting started with gSOAP

project page on SourceForge
*
XML data binding XML data binding refers to a means of representing information in an XML document as a business object in computer memory. This allows applications to access the data in the XML from the object rather than using the DOM or SAX to retrieve the da ...
* Serialization *
List of web service frameworks A list of web service frameworks: See also * Comparison of web frameworks * List of web service specifications * List of web service protocols * Web service * Java view technologies and frameworks * List of application servers This list comp ...
*
List of web service specifications There are a variety of specifications associated with web services. These specifications are in varying degrees of maturity and are maintained or supported by various standards bodies and entities. These specifications are the basic web services ...
Web services Web service specifications