Chapter 5 SOAP Example
Purpose and Overview
This example demonstrates how HydraExpress handles the any element and using a configuration file to resolve naming collisions between types and elements defined in the global scope. The example also demonstrates how HydraExpress generates code for more than one schema.
To demonstrate these features, the example generates C++ constructs for the SOAP schema. SOAP is an XML messaging protocol that provides an envelope for sending and receiving XML data and documents. The schema for SOAP uses the any element to allow any XML document to be contained within the body element of an envelope. From the SOAP schema, HydraExpress generates a class that represents the envelope and a class that represents the body.
Data to be stored within an element of any type must be packaged as a string (the body element in this case). You can either create the XML strings directly, or marshal the XML strings into the body class by using classes generated by HydraExpress.
Likewise, when extracting data from an element of any type, the result is a string containing XML. For simple content, the data is probably useful in this form. For complex content, however, you would probably want to parse the data into constituent elements. If the content of the element corresponds to classes generated by HydraExpress, you can use the generated classes to easily unmarshal the data. You can also parse the data directly using an XML parser.
“The SOAP XML Document” describes the SOAP document used in the example.
“Customizing Mappings Using the Project File” describes the use of a customized mapping identified in the provided project file.
The SOAP example includes two complete programs. The first program uses the
rwsf::XmlReader class of the RWSF Core Library to parse the data directly. The code for this example is provided in
soap_main.cpp.
“Generate Code” describes the parsing example. The second program uses classes generated by HydraExpress to parse and process the data. The code for this example is provided in
trade_main.cpp.
“Building and Compiling” describes the generated class example.