Hi all,
Property mediator in WSO2 ESB is a very useful mediator and can be use for various mediation purposes. In here I used property mediator to read SOAP element value.
1. I created a sequence with property mediator. Sample Configuration as follows:
<sequence name="propertySeq">
<property expression="//ser:getSimpleQuote/ser:symbol/text()"
name="testProperty" scope="default" type="STRING"
xmlns:ns="http://org.apache.synapse/xsd"
xmlns:ser="http://services.samples" xmlns:xsd="http://sample.wso2.org/xsd"/>
<log level="custom">
<property expression="get-property('testProperty')"
name="PropertyValue" xmlns:ns="http://org.apache.synapse/xsd"/>
</log>
</sequence>
2. I created a proxy service with above sequence.
<proxy name="propertyProx" startOnLoad="true" trace="disable" transports="http https">
<description/>
<target endpoint="SimpleStockQuote" inSequence="propertySeq"/>
</proxy>
<endpoint name="SimpleStockQuote">
<address uri="http://localhost:9000/services/SimpleStockQuoteService/"/>
</endpoint>
3. Invoke proxy service.
Note: Through property mediator, I will retrieve value of "symbol" and used logs to indicated retruved value.
Sample SOAP message will be as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.samples">
<soapenv:Header/>
<soapenv:Body>
<ser:getSimpleQuote>
<!--Optional:-->
<ser:symbol>WSO2</ser:symbol>
</ser:getSimpleQuote>
</soapenv:Body>
</soapenv:Envelope>
Logs should be illustrate as follows:
[2016-03-29 18:28:22,380] INFO - LogMediator PropertyValue = WSO2
Note: According to message type and according to the content you want to add to property mediator, you can change above configurations.
Happy Coding !! :)
No comments:
Post a Comment