You can retrieve SOAP headers from a response message by
creating a variable of type SOAPHeaders and then
mapping that variable to the SOAP header response.
Before you begin
This task requires that you have access to an integration
service with a web service integration component and a SOAP request
message.
Procedure
- Create a service flow and add a service task.
-
Create a private variable of the type SOAPHeaders.
This variable will receive the header entries from the SOAP response message.
- On the Data Mapping tab of the Properties
view, in the Output Header Mapping section, map your newly created
variable to the response SOAP header.
When the web service
invocation finishes, this variable is initialized for you and it contains
all the SOAP header entries from the SOAP response message.
- To access the headers that have been received by the variable, add JavaScript code to Post-execution Assignments on
the Pre & Post tab and add the code there.
The following
example shows how to access the header entries. In this example, the private variable
tw.local.responseHeaders is defined on the
Variables tab
and mapped to the response SOAP header on the
Data Mapping
tab.
var myHeader = new tw.object.SOAPHeader();
var numHeaders = tw.local.responseHeaders.headers.listLength();
for (var i = 0; i < numHeaders; i++) {
if (tw.local.responseHeaders.headers[i].name == "header1") {
myHeader = tw.local.responseHeaders.headers[i];
}
}
- Click Save or
Finish Editing.
For details about declaring
variables for the client-side human services, see
Declaring variables
-
Run the service flow by clicking Run Service and verify that the SOAP
headers are added to the request message and that the expected SOAP headers are retrieved from the
response SOAP message.
This topic is shared by BAW, CP4BA, CP4BASaaS. Last updated on 2025-03-13 12:15