Java Reference
In-Depth Information
xmlns:ns1="urn:xmethods-delayed-quotes"
SOAP-
ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<return xsi:type="xsd:float">133.625</return>
</ns1:getQuoteResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
SOAP Serialization
In addition to an XML call envelope, the SOAP specification includes a simple XML-based data
serialization format. The serialization formats standardized transmission of complex objects via SOAP
remote method calls. It serializes the top-level object to an XML element corresponding to the
classname, with embedded elements representing the properties. The following shows an example
SOAP serialization of a Person class. The nsp: prefix is an XML namespace prefix, determining the
namespace of the Person element. (XML namespaces can be compared to Java package names to
some extent. For more details about XML namespaces, refer to the W3C recommendation found on
http://www.w3.org/TR/1999/REC-xml-names-19990114/ or to Sams Teach Yourself XML in 21 Days,
Second Edition .)
Java class:
class Person {
String familyName;
String givenName;
}
SOAP serialized instance:
<nsp:Person>
<familyName>Turing</familyName>
<givenName>Adam</givenName>
</nsp:Person>
The SOAP serialization format is able to serialize complex object graphs. Related objects can be
serialized in a linked or embedded form. Single-referenced objects can be embedded in the referenced
object, whereas multi-referenced objects should be linked. The following shows a simple example of a
referenced object, serialized in both embedded and linked forms. Note that for embedded objects, there
is no separate element for the classname, reducing the nesting depth and keeping the format human
readable. However, for polymorphic properties, the classname must be contained in a type attribute of
the corresponding element. In SOAP, the remote method call and the response are also serialized as if
they were objects. For more details about SOAP, refer to Sams Publishing's Understanding SOAP: The
Authoritative Solution . The specification is available at http://www.w3.org/TR/SOAP/ .
Embedded objects:
<nsp:Person>
<familyName>Douglas</familyName>
<givenName>Mike</givenName>
<father>
<familyName>Douglas</familyName>
<givenName>Kirk</givenName>
</father>
</nsp:Person>
Linked objects:
<nsp:Person>
Search WWH ::




Custom Search