SOAPHTTPNC and SOAPHTTPNV
The SOAPHTTPNC and SOAPHTTPNV functions allow you to specify a complete SOAP message as input and to return complete SOAP messages from the specified web service. The returned SOAP messages are CLOB or VARCHAR representations of the returned XML data.
The schema is DB2XML.
- endpoint_url
- Specifies the URL of the web service for which DB2® is acting as a client. endpoint_url is
defined as a VARCHAR(4096) value. The URL is in the following format:
Where proto can be http or https.proto://[user[:password]@]hostname[:port]/[path]
- soap_action
- Specifies a SOAP action URI reference. soap_action is defined as a VARCHAR(4096) value. Depending on the web server, soap_action might be required. If it is required for the web service that is specified in endpoint_url, the required value is defined in the WSDL of that web service.
- soap_input
- Specifies an XML document that contains the complete SOAP message. soap_input can contain optional SOAP headers and must contain a SOAP body that specifies the operation name and parameters to the web service. soap_input should be well-formed XML that is defined as VARCHAR(32672) or CLOB(1M).
Example 1: The following
SQL statement retrieves information (as VARCHAR data) about a web
service:
SELECT DB2XML.SOAPHTTPNV(
'http://rpc.geocoder.us/service/soap/',
'"http://rpc.geocoder.us/Geo/Coder/US#geocode_address"',
'<?xml version="1.0" encoding="UTF-8" ?>' ||
'<SOAP-ENV:Envelope ' ||
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' ||
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' ||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ||
'<SOAP-ENV:Body>' ||
'<ns0:geocode_address ' ||
'xmlns:ns0="http://rpc.geocoder.us/Geo/Coder/US/" ' ||
'SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' ||
'<address xsi:type="xsd:string">555 Bailey Avenue, San Jose,' ||
'CA,95141</address>' ||
'</ns0:geocode_address>' ||
'</SOAP-ENV:Body>' ||
'</SOAP-ENV:Envelope>')
FROM SYSIBM.SYSDUMMY1;
Example 2: The
following SQL statement inserts the results (as CLOB data) from a
request to a web service into a table:
INSERT INTO EMPLOYEE(XMLCOL)
VALUES (DB2XML.SOAPHTTPNC(
'http://www.myserver.com/services/db2sample/list.dadx/SOAP',
'http://tempuri.org/db2sample/list.dadx',
'<?xml version="1.0" encoding="UTF-8" ?>' ||
'<SOAP-ENV:Envelope ' ||
'xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' ||
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' ||
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' ||
'<SOAP-ENV:Body>' ||
'<listDepartments xmlns="http://tempuri.org/db2sample/list.dadx">
<deptNo>A00</deptNo>
</listDepartments>' ||
'</SOAP-ENV:Body>' ||
'</SOAP-ENV:Envelope>'))