Saturday, January 24, 2015

Read the content stored in registry- WSO2 ESB


1.Lets say we have stored a XML file (order-id.xml) in registry.



2. I'm going to use Mock Service (Mockproxy) to read the content  and send back as a response (using respond mediator -ESB 4.8.x).

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="Mockproxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="order"
                   expression="get-property('registry','conf:/order-id.xml')"
                   scope="default"
                   type="OM"/>
         <payloadFactory media-type="xml">
            <format>
               <response>
                  <id>$1</id>
                  <symbol>$2</symbol>
               </response>
            </format>
            <args>
               <arg evaluator="xml" expression="$ctx:order//id"/>
               <arg evaluator="xml" expression="$ctx:order//symbol"/>
            </args>
         </payloadFactory>
         <respond/>
      </inSequence>
   </target>
   <description/>
</proxy>
3. Mockproxy test.

Request :
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Body></soapenv:Body>
</soapenv:Envelope>
Response:

<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Body>
      <response xmlns="http://ws.apache.org/ns/synapse">
         <id>1</id>
         <symbol>WSO2</symbol>
      </response>
   </soapenv:Body>
</soapenv:Envelope>