If you are already familiar with XPath and wish to configure the
expression manually, complete the following fields, using the examples
below if necessary:
-
Enter or select a name for the XPath expression in the
Name dropdown.
-
Enter the XPath expression to use in the
XPath Expression field.
-
In order to resolve any prefixes within the XPath expression, the
namespace mappings (i.e. Prefix,
URI) should be entered in the table.
Let's take a look at an example. Consider the following SOAP message:
| | |
|
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" id="sample">
...............
...............
...............
...............
</dsig:Signature>
</soap:Header>
<soap:Body>
<prod:product xmlns:prod="http://www.oracle.com">
<prod:name>SOA Product*</prod:name>
<prod:company>Company</prod:company>
<prod:description>WebServices Security</prod:description>
</prod:product>
</soap:Body>
</soap:Envelope>
| |
| | |
|
The following XPath expression evaluates to true if the
<name> element contains the value
Enterprise Gateway:
XPath Expression: //prod:name[text()='Enterprise Gateway']
In this case, it is necessary to define a mapping for the
prod namespace as follows:
Prefix |
URI |
prod |
http://www.oracle.com |
Let's look at another example. This time the element that is to be
examined belongs to a default namespace. Consider the following SOAP
message:
| | |
|
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Header>
<dsig:Signature xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" id="sample">
...............
...............
...............
...............
</dsig:Signature>
</soap:Header>
<soap:Body>
<product xmlns="http://www.company.com">
<name>SOA Product</name>
<company>Company</company>
<description>WebServices Security</description>
</product>
</soap:Body>
</soap:Envelope>
| |
| | |
|
The following XPath expression evaluates to true if the
<company> element contains the value
Company:
XPath Expression: //ns:company[text()='Company']
Since the <company> element actually belongs
to the default (xmlns) namespace, i.e.
http://www.company.com, it is necessary to make up
an arbitrary prefix, ns, for use in the XPath
expression and assign it to http://www.company.com.
This is necessary to distinguish between potentially several default
namespaces which may exist throughout the XML message. The following
mapping illustrates this:
Prefix |
URI |
ns |
http://www.oracle.com |
Returning a NodeSet:
Both of the examples above dealt with cases where the XPath expression
evaluated to a Boolean value. For example, the expression in the above
example asks, "Does the <company> element in
the http://www.oracle.com namespace contain a text node with the
value 'oracle'?".
It is sometimes necessary to use the XPath expression to return a subset
of the XML message. For example, when using an XPath expression to
determine what nodes should be signed in a signed XML message, or when
retrieving the nodeset to validate against an XML Schema.
The Enterprise Gateway ships with such an XPath expression: one that returns
"All Elements inside SOAP Body". To view this expression, select it
from the Name field. It appears as follows:
XPath Expression: /soap:Envelope/soap:Body//*
This XPath expression simply returns all child elements of the SOAP
<Body> element. To construct and test more
complicateD expressions, administrators are advised to use the
XPath Wizard.
|