Main Page | Class List | File List | Class Members | File Members | Related Pages

# Addressbook Documentation

### 1.0

address.cpp

Address book example XML data binding application.

Illustrates the gSOAP XML data binding with wsdl2h and soappcp2.

Copyright (C) 2000-2009 Robert A. van Engelen. All Rights Reserved.

Project Source Files

- address.xsd Address book
- address.cpp Address book app (reads/writes address.xml file)
- addresstypemap.dat Schema namespace prefix name preference

Generated Files

- address.h gSOAP data binding definitions from address.xsd
- addressStub.h C++ data binding definitions
- addressH.h Serializers
- addressC.cpp Serializers
- a.nsmap XML namespace mapping file (binds 'a' URI)
- address.xml Address book data generated by address

Compile:

- wsdl2h -g -t addresstypemap.dat address.xsd
- soapcpp2 -2 -CS -I../../import -p address address.h
- g++ -I../.. address.cpp addressC.cpp -o address ../../stdsoap2.cpp

Run:

- ./address

Additional notes:

- To instantiate class X in the engine's data space, we use the auto-generated soap_new_X(soap, -1). This allows easy deallocation with soap_destroy(soap). Use soap_new_X(soap, N) to allocate an array of N objects
- X::soap_default(soap) sets X members to default values. For C types use soap_default_X(soap, X*) to initialize values of type X
- To convert enum constants to string, we use the auto-generated soap_X2s(soap, enum X) function
- To convert a string to an enum constant, we use the auto-generated soap_s2X(soap, const char*, enum X*) function
- The struct soap context is initialized with the following flags: SOAP_XML_STRICT: strictly validates XML (reader); SOAP_XML_INDENT: produces indented XML (writer); SOAP_XML_TREE: output tree XML for co-referenced objects in object graph. Otherwise, co-referenced objects are encoded as per SOAP multi-ref encoding (writer); SOAP_XML_CANONICAL: improves XML output by removing unnecessary xmlns bindings (writer).
- If multi-ref objects are serialized with SOAP encoding, the co-references are preserved in the XML-serialized output using 'id' and 'ref' attributes for cross referencing. To ensure an accurate mapping of the XML object graph after serilaization. We advice to use the SOAP1.2 standard. Therefore, soapcpp2 option -2 is used. The SOAP_XML_STRICT and SOAP_XML_CANONICAL flags cannot be used with SOAP encoding formats.