The SOAPHTTPNV and SOAPHTTPNC user-defined functions

Db2 provides SOAPHTTPNV and SOAPHTTPNC user-defined functions that allow you to work with SOAP and consume web services in SQL statements. The user-defined functions are two varieties of SOAPHTTPNV for VARCHAR data and two varieties of SOAPHTTPNC for CLOB data.

The user-defined functions perform the following actions:
  1. Post the input SOAP request to the service endpoint
  2. Receive and return the SOAP response

SOAPHTTPNV and SOAPHTTPNC allow you to specify a complete SOAP message as input and return complete SOAP messages from the specified web service as a CLOB or VARCHAR representation of the returned XML data. . SOAPHTTPNV returns VARCHAR(32672) data and SOAPHTTPNC returns CLOB(1M) data. Both functions accept either VARCHAR(32672) or CLOB(1M) as the input body.

SOAPHTTPNV and SOAPHTTPNC user-defined functions can support SOAP 1.1 or SOAP 1.2. Check with your system administrator to determine which levels of SOAP are supported by the user-defined functions in your environment.

Example

The following example shows how to insert the complete result from a web service into a table using SOAPHTTPNC.

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