SOA Security Manager Gateway Validating a SOAP Header Manifest Against the Body Root Element

Document ID : KB000024020
Last Modified Date : 14/02/2018
Show Technical Document Details


This document presents an example of the SOA Security Manager Gateway validating a SOAP header manifest against the body root element.



Given the following XML:

<?xml version="1.0" encoding="UTF-8"?>
          <starws:manifest contentID="Content0"
                   element="ProcessPartsOrder" version="5.3.2" />
                <starws:content id="Content0">

In this example we want to validate "ProcessPartsOrder" in the soap header against the name of element "ProcessPartsOrder". We need to see that the element with name identified by the attribute element "" and namespace identified by the attribute "namespaceURI" in the element "manifest".

This is how you could do it:

Figure 1

  1. Extract the value of the "element" and "namespaceURI" attribute using two XPath filters ("Attributes" > "Retrieve from message" filter).

    "Retrieve from message - element attribute" filter is configured as shown:

    Figure 2

    Figure 3

    "Retrieve from message - namespace attribute" filter is configured as shown:

    Figure 4

    Figure 5

  2. Use the "Utility" > "Scripting" filter to do your custom validation, based on the attributes retrieved in step1. In this case I'm just testing for the presence of the element in the given namespace:
    function invoke(msg)
        var elementName = msg.get("elementName");
        var namespaceURI = msg.get("namespaceURI");
        // look in the doc for the element
        var body = XMLBody.locate(msg);
        var doc = body.getDocument();
        var root = doc.getDocumentElement();
        var nodes = 
              root.getElementsByTagNameNS(namespaceURI, elementName);
        if ((nodes == null) || (nodes.getLength() <= 0)) {
              Trace.error("The element " + elementName  + " was not found in message");
              return false;
        Trace.error("Found the element " + elementName);
        return true;      
    Figure 6