In the XML schema for the input and output messages for the operation, the native XML data type is mapped to xsd:anyType.
If an XML message to a Web service requests an INSERT or UPDATE, the parameter tag must contain a valid XML document.
The examples in the following two sections perform operations on the CUSTOMER table of the DB2 SAMPLE database.
Name of column | Data type |
---|---|
CID | BIGINT |
INFO | XML |
HISTORY | XML |
The following default XML schema is for an operation that is based on the following SQL statement:
INSERT INTO CUSTOMER (CID, INFO, HISTORY)
VALUES (:cid, :info, :history)
The columns INFO and HISTORY contain XML data. The elements that represent these columns in the schema are highlighted in bold:
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:example" xmlns:tns="urn:example">
<xsd:element name="insertCustomer">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="cid" type="xsd:long" nillable="true"></xsd:element>
<xsd:element name="info" type="xsd:anyType" nillable="true"></xsd:element>
<xsd:element name="history" type="xsd:anyType" nillable="true"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="insertCustomerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="updateCount" type="xsd:int"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
A SOAP/HTTP request might look like this example:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="urn:example">
<soapenv:Body>
<q0:insertCustomer>
<cid>123456</cid>
<info>
<customerinfo>
<name>Amir Malik</name>
<addr country="United States">
<street>555 Bailey Ave</street>
<city>San Jose</city>
<prov-state>California</prov-state>
<pcode-zip>95141</pcode-zip>
</addr>
<phone type="work">408-555-1358</phone>
</customerinfo>
</info>
<history>
<customerHistory>
<numberOrders>12</numberOrders>
<memberSince>1999</memberSince>
</customerHistory>
</history>
</q0:insertCustomer>
</soapenv:Body>
</soapenv:Envelope>
The following default XML schema is for an operation that is based on the following SQL statement:
SELECT CID, INFO, HISTORY
FROM CUSTOMER
As in the preceding example, the columns INFO and HISTORY contain XML data. The elements that represent these columns in the schema are highlighted in bold:
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="urn:example" xmlns:tns="urn:example">
<xsd:element name="selectCustomer">
<xsd:complexType></xsd:complexType>
</xsd:element>
<xsd:element name="selectCustomerResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element maxOccurs="unbounded" minOccurs="0" name="row">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="CID" type="xsd:long"></xsd:element>
<xsd:element name="INFO" type="xsd:anyType" nillable="true"></xsd:element>
<xsd:element name="HISTORY" type="xsd:anyType" nillable="true"></xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
A SOAP/HTTP response might look like this example:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="urn:example">
<soapenv:Body>
<q0:selectCustomerResponse>
<row>
<cid>123456</cid>
<info>
<customerinfo>
<name>Amir Malik</name>
<addr country="United States">
<street>555 Bailey Ave</street>
<city>San Jose</city>
<prov-state>California</prov-state>
<pcode-zip>95141</pcode-zip>
</addr>
<phone type="work">408-555-1358</phone>
</customerinfo>
</info>
<history>
<customerHistory>
<numberOrders>12</numberOrders>
<memberSince>1999</memberSince>
</customerHistory>
</history>
</row>
</q0:selectCustomerResponse>
</soapenv:Body>
</soapenv:Envelope>