...
Code Block | ||
---|---|---|
| ||
<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 following StockQuote request using sample stockquote client as followsthe sample StockQuote client. For information on the sample client, refer to the Sample Clients sub heading in ESB Samples Setup.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy
...
The SOAP 1.1 or 1.2 header element. For example, the expression =" $header/wsa:To refers to the addressing To header regardless of whether this message is SOAP-11 or SOAP-12.SOAP-12. We have discussed an example below.
Example of $Header usage:
1. Deploy the following proxy service using instructions in Adding a Proxy Service.
Note the property, <property xmlns:wsa="http://www.w3.org/2005/08/addressing" name="stockprop" expression="$header/wsa:To"/> in the configuration. It is used to log the value of wsa:To header of the SOAP request.
Code Block | ||
---|---|---|
| ||
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log>
<property xmlns:wsa="http://www.w3.org/2005/08/addressing" name="stockprop" expression="$header/wsa:To"/>
</log>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description></description>
</proxy> |
2. Send the following StockQuote request using the sample StockQuote client. For information on the sample client, refer to the Sample Clients sub heading in ESB Samples Setup.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy
3. Note the following message in the ESB log.
Code Block |
---|
[2013-03-18 14:14:16,356] INFO - LogMediator To: http://localhost:9000/services/SimpleStockQuoteService, WSAction: urn:getQuote, SOAPAction: urn:getQuote, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:8a64c9cb-b82f-4d6f-a45d-bef37f8b664a, Direction: request,
stockprop = http://localhost:9000/services/SimpleStockQuoteService |
$axis2
Prefix for Axis2 MessageContext properties. This is used to get the property value at the axis2 scope. For example, to get the value of Axis2 message context property with name REST_URL_POSTFIX, use the XPath expression $axis2:REST_URL_POSTFIX. We have discussed an example below.
...
Code Block | ||
---|---|---|
| ||
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <log> <property name="stockprop" expression="$axis2:REST_URL_POSTFIX"/> </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 followsfollowing StockQuote request using the sample StockQuote client. For information on the sample client, refer to the Sample Clients sub heading in ESB Samples Setup.
ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy/test/prefix
...
Code Block | ||
---|---|---|
| ||
<proxy xmlns="http://ws.apache.org/ns/synapse" name="StockQuoteProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <send> <endpoint key="ep2"/> </send> </inSequence> <outSequence> <send/> </outSequence> <faultSequence> <log> <property name="stockerrorprop" expression="$ctx:ERROR_MESSAGE"/> <property name="Cause" expression="get-property('ERROR_MESSAGE')"/> </log> </faultSequence> </target> <description></description> </proxy> |
2. Send a the following StockQuote request using the sample StockQuote client as followsclient. For information on the sample client, refer to the Sample Clients sub heading in ESB Samples Setup.
ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy
...