IBM Support

How can I pass values in the header of a SOAP Request using Web Services Stages

Question & Answer


Question

I want to invoke a Web Service that requires to pass values in the header of the SOAP Request for authentication. How can I pass these values using Web Services Stages?

Answer

Some Web Services require you to send information (eg. credentials) in the header of the SOAP request. To accomplish this you need to manually build the entire header and then send this in an input column of the Web Service stage. Follow these instructions:

1. Obtain a valid SOAP request that you have tested outside of DataStage. Extract the header from the request. This is just example:

<soapenv:Header>
<tns:UserInfoHeader
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:tns="http://www.mysite.com/webservices/mytns"&gt;
<tns:userid>testuser</tns:userid>
<tns:password>testpassword</tns:password>
</tns:UserInfoHeader>
</soapenv:Header>

2. This header needs to be passed as an XML chunk to the Web Service Stage. Because of this the header will be treated as a separate entity and requires to have a fully qualified namespace in the XML root element. You cannot use the default empty (xmlns="") namespace. If no namespace is provided using you may get errors like these (depending on the version of DataStage that you are using):

Java.lang.NullPointerException at com.ascentialsoftware.wsclient.xml.TreeBuilder.build(TreeBuilder.java:117)

or

com.ascentialsoftware.wsclient.ServiceInvocationException: Service invocation exception: The prefix "soapenv" for element "soapenv:Header" is not bound.

For this example, the header should look like this:

<soapenv:Header xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<tns:UserInfoHeader
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/&quot;
xmlns:tns="http://www.mysite.com/webservices/mytns"&gt;
<tns:userid>testuser</tns:userid>
<tns:password>testpassword</tns:password>
</tns:UserInfoHeader>
</soapenv:Header>


3. Add an input column to the Web Service Stage and pass this value using that column. This column should be a new column and not one of the input columns created when you imported the WSDL.

4. Open the Web Service stage, click "Input", "Input Header", check the checkbox "User-Defined Header" and then choose the column that contains the header.

[{"Product":{"code":"SSZJPZ","label":"IBM InfoSphere Information Server"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"--","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.5;8.1;8.0.1;7.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21501572