Skip to main content
Skip table of contents

SOAP Headers within Service Context

Example File (Builder projectAdd-ons/SOAP):

<your example path>\Add-ons\SOAP\soapHeader.xml

The SOAP header is an optional element of a soap request or response. In the header section, meta information on the actual soap message can be set. These meta information can hold additional information about routing of the message, information on encryption or affiliation to a transaction.
The SOAP header can only exist once within a message and has to be the first element within the SOAP envelope. The header though can consist of multiple SOAP header elements. These header blocks are identified via a unique URI and, through that, can be assigned to specific nodes within the message structure. Through this mechanism, the SOAP message stays flexible and can be extended by specifying additional header blocks. The communicating partners do not need any specifications on these header blocks.

The content of these headers can be of any information. A typical usage in practice would be the transfer of security information or setting a transaction ID as the following example shows:

HTML/XML
<?xml version="1.0" ?>
<env:Envelope xmlns:env="http://www.w3.org/2002/12/soap-envelope">
  <env:Header>
    <login:security xmlns:login="http://example.com" env:role="http://example.com/Login" env:mustUnderstand="true">
      <login:username>Simon Sample</login:username> 
      <login:password>aPassword</login:password>
    </login:security>
    <bridge:TransactionID xmlns:bridge="http://e2e.ch/bridge">dkdme44546kkjdkcvdfldkjvopinmoisf</bridge:TransactionID>
  </env:Header> 
  <env:Body > ... ... </env:Body>
</env:Envelope>
The SOAP message does not necessarily need to be sent from one sender to one receiver. The message can also reach its goal over intermediate stations. The elements can directly be addressed to these intermediate services assuming they understand and process the header information.

Reading the SOAP Headers of a service within the service context

The SOAP headers are read from the service context via the operation getSOAPHeaders(). The operation returns an array of SOAPHeaderElements. The result can then be read and processed.

The following example reads the SOAP headers from the service context and reads the header array into the object soapHeaderArray for further parsing (xmlToClass()):

If a header element CorrelationID contains a correlation ID (e.g. set by the SOAP adapter),  it will be logged to the transaction log (see Contents of the Transaction Log).

Setting the SOAP Headers of a service within the service context

The E2E Bridge is capable of creating custom SOAP headers elements with a build-in function setSOAPHeaders(). The function is called within the service context and needs an array of SOAPHeaderElement objects as an input. The following example shows how to create a simple SOAP header block and set it to the services context.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.