Adding SOAP headers to a SOAP request message

You can add a SOAP header to a request message by creating a variable of type SOAPHeader or SOAPHeaders. You can then map that variable to the SOAP header request.

Procedure

  1. Create a private variable:
    • In Process Designer, create a service flow and add a service task.
    • In the desktop Process Designer, create an integration service that includes a web service integration component.
  2. Select the service task or web service integration component and click the Variables tab above the diagram area.
  3. Create the private variable that you will later map to the SOAP header of the request message. To add a single header entry to the request message, use the variable type SOAPHeader. To add multiple headers to the request message, use the variable type SOAPHeaders.
  4. Initialize the variable that you created in step 3.
    You can initialize the variable in three ways:
    • Define a default value on the page where you created the variable.
    • Add JavaScript code to a server script component.
    • Click Pre & Post and add JavaScript code to the Pre-execution Assignments section
    The following example of JavaScript code initializes a private variable, requestHeader, which is of the type SOAPHeader and contains a single header entry:
    tw.local.requestHeader.name = "sessionId";
    tw.local.requestHeader.nameSpace = "http://acme.com";
    tw.local.requestHeader.value = "<x:sessionId xmlns:x=\"http://acme.com\">1237314</x:sessionId>";
    Note: Make sure namespaces are fully qualified, as they are in the examples.
    Note: Try to avoid white spaces in a SOAP header value. Best practice is to add the XML snippet without any extra white space.
    You can include more than one header. The following example of JavaScript code initializes two SOAP headers and adds them to the requestHeaders private variable, which is of the type SOAPHeaders and contains multiple headers:
    // Initialize the "subscriptionId" header
    var header1 = new tw.object.SOAPHeader();
    header1.name = "subscriptionId";
    header1.nameSpace = "http://acme.com";
    header1.value = "<x:subscriptionId xmlns:x=\"http://acme.com\">123-4567-9012</x:subscriptionId>";  
    
    // Initialize the "auditLogUUID" header 
    var header2 = new tw.object.SOAPHeader(); 
    header2.name = "auditLogUUID"; 
    header2.nameSpace = "http://acme.com"; 
    header2.value = "<x:auditLogUUID xmlns:x=\"http://acme.com\">ab74-ffce-3333-feab</x:auditLogUUID>";  
    
    // Now add the two headers to the SOAPHeaders variable 
    tw.local.requestHeaders.headers[0] = header1; 
    tw.local.requestHeaders.headers[1] = header2;
  5. On the Data Mapping tab of the Properties view, in the Input Header Mapping section, add your newly created variable (either requestHeader or requestHeaders) to map it to a request SOAP header.
  6. Complete the definition of the web service integration.
  7. Click Save or Finish Editing.
  8. Run the service flow or integration service by clicking Run Service and verify that the SOAP headers are added to the request message.