WAS v8.5 > Reference > Developer best practices

Map XML schema definitions to the SDO type system

Each XML schema type is mapped to an SDO type. Use this mapping to help develop code to navigate the data graphs of the messages that your program mediates.

The version of Service Data Objects (SDO) supported by mediations is v1.

XML schemas can be embedded in the WSDL sections that describe the message parts and SOAP headers. However the SOAP header description is more likely to be available as a separate schema, in which case you should load it into the SDO repository where it can be used at run time to process any message with a matching header.


Schema to Java class mapping

Each XML schema complex type is mapped to an SDO type. This means that an element with a complex type is represented by an instance of an SDO data object. The type has a property for each element, attribute, or wildcard contained in the schema type definition.

The instance contains a value for each property that has been set. If the property is mapped from a schema complex type, the value is another SDO data object. If the property is mapped from a schema simple type, the value is an instance of a Java class, as shown in the following table.

Schema types and corresponding Java classes. The first column of the table lists the schema types. The second column lists the corresponding Java classes. The third column refers you to one of the two notes that is given at the end of the table for the reference.

Schema type Java class Notes
anyURI java.lang.String  
base64Binary byte[] See Note 2
boolean java.lang.Boolean/ boolean See Note 1
byte java.lang.Byte / byte See Note 1
date java.lang.String  
dateTime java.lang.String  
decimal java.math.BigDecimal  
double java.lang.Double / double See Note 1
duration java.lang.String  
ENTITIES java.util.List  
ENTITY java.lang.String  
float ava.lang.Float / float See Note 1
gDay java.lang.String  
gMonth java.lang.String  
gMonthDay java.lang.String  
gYear java.lang.String  
gYearMonth java.lang.String  
hexBinary byte[] See Note 2
ID java.lang.String  
IDREF java.lang.String  
IDREFS java.util.List  
int java.lang.Integer / int See Note 1
integer java.math.BigInteger  
language java.lang.String  
long java.lang.Long / long See Note 1
Name java.lang.String  
NCName java.lang.String  
negativeInteger java.math.BigInteger  
NKTOKENS java.util.List  
NMTOKEN java.lang.String  
nonNegativeInteger java.math.BigInteger  
nonPositiveInteger java.math.BigInteger  
normalisedString java.lang.String  
NOTATION javax.xml.namespace.QName  
positiveInteger java.math.BigInteger  
QName javax.xml.namespace.QName  
short java.lang.Short / short See Note 1
string java.lang.String  
time java.lang.String  
token java.lang.String  
unsignedByte java.lang.Short / short See Note 1
unsignedInt java.lang.Long / long See Note 1
unsignedLong java.math.BigInteger  
unsignedShort java.lang.Integer / int See Note 1

Notes:

  1. SDO automatically converts primitives (int, long and so on) into objects, as needed. This means that we can use a mixture of the specialized methods (getInt, setInt, getLong, setLong) as well as the generic get and set methods.
  2. As byte arrays are mutable, we can update the value without setting it back onto the data object. However, when this occurs, the data object may not be aware of implicit update. When working with byte array values, always use the setBytes() method to explicitly update the data object.


Work with global elements and attributes

When a schema is mapped to SDO, a special SDO type - typically called 'DocumentRoot' - is defined. This type is a container for all the global elements and attributes in the schema. Whenever we have to locate an SDO property for a global element or attribute, you should locate the ‘DocumentRoot' type and then locate the appropriate property within it.

The following schema defines the layout of web services messages. By comparing this schema with the information in Map of SDO data graphs for web services messages we can see the schema to SDO mapping in action.

<?xml version="1.0"?> <xsd:schema
    targetNamespace="http://www.ibm.com/ns/2004/05/webservices/messagemodel"
    xmlns:tns="http://www.ibm.com/ns/2004/05/webservices/messagemodel"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
 <xsd:import namespace="http://schemas.xmlsoap.org/soap/envelope/"/> 
    <xsd:element name="Info">       <xsd:complexType>         <xsd:sequence>           <xsd:element name="operationName" nillable="true" type="xsd:string"/>           <xsd:element name="messageName"   nillable="true" type="xsd:string"/>           <xsd:element name="messageType"   nillable="true" type="xsd:string"/>           <xsd:element name="headers"       type="tns:HeaderEntryType"     maxOccurs="unbounded"/>           <xsd:element name="attachments"   type="tns:AttachmentEntryType" maxOccurs="unbounded"/>           <xsd:element name="body"          type="tns:BodyType"/>         </xsd:sequence>       </xsd:complexType>     </xsd:element> 
    <xsd:complexType name="BodyType" abstract="true"/> 
    <xsd:complexType name="HeaderEntryType" abstract="true"/> 
    <xsd:complexType name="AttachmentEntryType" abstract="true"/> 
    <xsd:complexType name="SOAPFaultBody">       <xsd:complexContent>         <xsd:extension base="tns:BodyType">           <xsd:sequence>             <xsd:element name="faultcode" type="xsd:QName"/>             <xsd:element name="faultstring" type="xsd:string"/>             <xsd:element name="faultactor" type="xsd:anyURI" minOccurs="0"/>             <xsd:element name="detail" type="soap:detail" minOccurs="0"/> 
    </xsd:sequence>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType>     
    <xsd:complexType name="SOAP_1_1_HeaderEntryType">       <xsd:complexContent>         <xsd:extension base="tns:HeaderEntryType">           <xsd:sequence>             <xsd:element name="mustUnderstand" nillable="true" type="xsd:boolean"/>             <xsd:element name="actor"          nillable="true" type="xsd:anyURI"/>             <xsd:any/>           </xsd:sequence>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType>     
    <xsd:complexType name="SOAP_1_1_BoundHeaderEntryType">       <xsd:complexContent>         <xsd:extension base="tns:HeaderEntryType">           <xsd:sequence>             <xsd:element name="mustUnderstand" nillable="true" type="xsd:boolean"/>             <xsd:element name="actor"          nillable="true" type="xsd:anyURI"/>             <xsd:element name="messagePart"    type="xsd:string"/>           </xsd:sequence>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType> 
    <xsd:complexType name="MIMEAttachmentEntryType">       <xsd:complexContent>         <xsd:extension base="tns:AttachmentEntryType">           <xsd:sequence>             <xsd:element name="contentType"             type="xsd:string"/>             <xsd:element name="contentTransferEncoding" type="xsd:string"/>             <xsd:element name="contentId"               type="xsd:string"/>             <xsd:element name="data"                    type="xsd:base64Binary"/>           </xsd:sequence>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType> 
    <xsd:complexType name="BoundMIMEAttachmentEntryType">       <xsd:complexContent>         <xsd:extension base="tns:AttachmentEntryType">           <xsd:sequence>             <xsd:element name="contentType"             type="xsd:string"/>             <xsd:element name="contentTransferEncoding" type="xsd:string"/>             <xsd:element name="contentId"               type="xsd:string"/>             <xsd:element name="messagePart"             type="xsd:string"/>           </xsd:sequence>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType>     
    <xsd:complexType name="UnknownBodyType">       <xsd:complexContent>         <xsd:extension base="tns:BodyType">           <xsd:sequence>             <xsd:any/>           </xsd:sequence>           <xsd:attribute name="encodingStyle" type="xsd:string"/>         </xsd:extension>       </xsd:complexContent>     </xsd:complexType> 
</xsd:schema>       


Related concepts:

SDO data graphs


Related


Including SOAP header schemas in the SDO repository


+

Search Tips   |   Advanced Search