Wednesday, November 20, 2013

Callout Meditor to Invoke REST Services

Following configuration allows you to invoke RESTful services via CalloutMeditator

P.N you need to change axis2_client.xml Required to add JSON message formatter in ESB_470_HOME/samples/axis2Client/client_repo/conf/axis2.xml



<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="CalloutProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <property name="enableREST"
                   value="true"
                   scope="axis2-client"
                   type="BOOLEAN"/>
         <property name="messageType"
                   value="application/json"
                   scope="axis2-client"
                   type="STRING"/>
         <property name="contentType"
                   value="application/json"
                   scope="axis2-client"
                   type="STRING"/>
         <callout serviceURL="http://localhost:9001/services/SimpleStockQuoteService"
                  action="urn:getQuote"
                  initAxis2ClientOptions="false">
            <source xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
            <target xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
                    xmlns:s11="http://schemas.xmlsoap.org/soap/envelope/"
                    xpath="s11:Body/child::*[fn:position()=1] | s12:Body/child::*[fn:position()=1]"/>
         </callout>
         <property name="RESPONSE" value="true"/>
         <header name="To" action="remove"/>
         <send/>
         <drop/>
      </inSequence>
   </target>
   <description/>
</proxy>


Wire logs

log4j.logger.httpclient.wire.header=DEBUG
log4j.logger.httpclient.wire.content=DEBUG

logs seen in console

[2013-11-20 17:38:18,840]  INFO - CarbonUIServiceComponent Mgt Console URL  : https://10.100.1.122:9443/carbon/
[2013-11-20 17:39:39,459] DEBUG - header >> "POST /services/SimpleStockQuoteService HTTP/1.1[\r][\n]"
[2013-11-20 17:39:39,468] DEBUG - header >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2013-11-20 17:39:39,469] DEBUG - header >> "Accept-Encoding: gzip,deflate[\r][\n]"
[2013-11-20 17:39:39,469] DEBUG - header >> "User-Agent: Axis2[\r][\n]"
[2013-11-20 17:39:39,469] DEBUG - header >> "Host: localhost:9001[\r][\n]"
[2013-11-20 17:39:39,469] DEBUG - header >> "Transfer-Encoding: chunked[\r][\n]"
[2013-11-20 17:39:39,469] DEBUG - header >> "[\r][\n]"
[2013-11-20 17:39:39,480] DEBUG - content >> "27[\r][\n]"
[2013-11-20 17:39:39,480] DEBUG - content >> "{"getQuote":{"request":{"symbol":"?"}}}"
[2013-11-20 17:39:39,480] DEBUG - content >> "[\r][\n]"
[2013-11-20 17:39:39,480] DEBUG - content >> "0"
[2013-11-20 17:39:39,480] DEBUG - content >> "[\r][\n]"
[2013-11-20 17:39:39,480] DEBUG - content >> "[\r][\n]"


                                

No comments:

Post a Comment