웹 서비스 조작의 DB2 기본 XML 데이터 유형에 대한 지원

웹 서비스의 조작은 기본 XML 데이터 유형을 사용하는 DB2® 컬럼을 참조할 수 있습니다.

조작에 대한 입력 및 출력 메시지의 XML 스키마에서 기본 XML 데이터 유형은 xsd:anyType에 맵핑됩니다.

웹 서비스에 대한 XML 메시지가 INSERT 또는 UPDATE를 요청하는 경우, 매개변수 태그에 유효한 XML 문서가 포함되어야 합니다.

다음 두 섹션의 예에서는 DB2 SAMPLE 데이터베이스의 CUSTOMER 테이블에 대한 조작을 수행합니다.

표 1. CUSTOMER 테이블의 컬럼
컬럼 이름 데이터 유형
CID BIGINT
INFO XML
HISTORY XML

INSERT문에서 DB2 기본 XML 데이터 유형 사용

다음 디폴트 XML 스키마는 다음 SQL문을 기반으로 하는 조작에 대한 것입니다.

INSERT INTO CUSTOMER (CID, INFO, HISTORY)
  VALUES (:cid, :info, :history)

INFO 및 HISTORY 컬럼에는 XML 데이터가 포함되어 있습니다. 스키마에서 이러한 컬럼을 표시하는 요소는 굵은체로 강조표시됩니다.

<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>

SOAP/HTTP 요청은 다음 예와 같이 표시될 수 있습니다.

<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>

쿼리에서 DB2 기본 XML 데이터 유형 사용

다음 디폴트 XML 스키마는 다음 SQL문을 기반으로 하는 조작에 대한 것입니다.

SELECT CID, INFO, HISTORY
  FROM CUSTOMER

이전 예에서와 같이 INFO 및 HISTORY 컬럼에는 XML 데이터가 포함되어 있습니다. 스키마에서 이러한 컬럼을 표시하는 요소는 굵은체로 강조표시됩니다.

<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>

SOAP/HTTP 응답은 다음 예와 같이 표시될 수 있습니다.

<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>

피드백