Question

I have created a proxy service who transform a message using a xslt mediator and then transformed to JSON, I want now to post the JSON message in a rest web service how i can do that directely in my proxy service? This is my proxy service :

<proxy xmlns="http://ws.apache.org/ns/synapse" name="CategoryProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>
         <property name="Authorization" expression="fn:concat('Basic ', base64Encode('admin:admin'))" scope="transport" type="STRING"/>
         <send>
            <endpoint>
               <address uri="http://localhost:8068/database/library.author/301"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <xslt key="conf:/ressources/catXsl.xsl"/>
         <property name="messageType" value="application/json" scope="axis2" type="STRING"/>
         <send/>
      </outSequence>
      <faultSequence/>
   </target>
   <description></description>
</proxy>

I want the message sent by this proxy to be post in a rest web ressource, How I can do it in my proxy?

Was it helpful?

Solution

Looks like you are looking for service chaining and you can do that in two ways:

1) Using a receiving sequence

  <inSequence>
     <property name="Authorization" expression="fn:concat('Basic ', base64Encode('admin:admin'))" scope="transport" type="STRING"/>
     <send receive="receivingSeqForChaining">
        <endpoint>
           <address uri="http://localhost:8068/database/library.author/301"/>
        </endpoint>
     </send>
  </inSequence>

You can define whatever sequence of operations you want in that receiving sequence. Output from this will be handed out to receiving sequence. If you don't want to do any specific action in outSequence for this case you can just add a to that.

2) Using outSequence to trigger other service call

You can also make that http call directly from outSequence something like this:

<outSequence>
<send>
            <endpoint>
               <http method="get"
                     uri-template="https://www.abc.com/resource/foo"/>
            </endpoint>
         </send>
</outSequence>

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top