Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

There is a set of predefined XPath variables that you can directly use to write XPaths in the Synapse configuration, instead of using the synapse:get-property() function. These XPath variables get properties of various scopes as follows:

...

  1. $body
  2. $Header
  3. $axis2
  4. $ctx
  5. $trp

$body

The SOAP 1.1 or 1.2 body element. For example, the expression ="$body/getQuote" refers to the first getQuote element in the a SOAP body, regardless of whether the message is SOAP-11 or SOAP-12. We have discussed an example below.

Example of $body usage:

1. Deploy the following proxy service using instructions in Adding a Proxy Service.

Note the property, <property xmlns:m0="http://services.samples" name="stockprop" expression="$body/m0:getQuote"/> in the configuration. It is used to log the first <m0:getQuote> element of the request SOAP body.

Code Block
languagehtml/xml
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <log>
            <property xmlns:m0="http://services.samples" name="stockprop" expression="$body/m0:getQuote"/>
         </log>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy> 

2. Send the StockQuoteRequest using sample stockquote client as follows.

ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy

3. Note the following message in the ESB log.

Code Block
[2013-03-18 14:04:41,019] INFO - LogMediator To: /services/StockQuoteProxy, WSAction: urn:getQuote, SOAPAction: urn:getQuote, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:930f68f5-199a-4eff-90d2-ea679c2362ab, Direction: request, stockprop = <m0:getQuotexmlns:m0="http://services.samples"><m0:request><m0:symbol>IBM</m0:symbol></m0:request></m0:getQuote>

Header

The SOAP 1.1 or 1.2 header element. For example, expression="$header/wsa:To refers to the addressing To header regardless of whether this message is SOAP-11 or SOAP-12.

...