Friday, July 12, 2013

How to test the disable HTTP chunking for outgoing messaging via WSO2 ESB and a REST request



There are few HTTP transport-specific properties in ESB.

Properties use in ESB access various types of information regarding a message that passes through the ESB. Also properties can be used to control the behavior of the ESB on a given message.

WSO2 ESB support transfer-encoding – chunked by default. To make it disabled, there is a property that would help to perform it.
 
      <property name="DISABLE_CHUNKING" value="true" scope="axis2"/>  


Transfer-encoding - chunked is a feature came along with HTTP 1.1. Therefore no matter what HTTP 1.0 will support only content type. Therefore if the message is forced to send as HTTP1.0 you will be able to see only the content type. Refer the previous blog post for more reference. Outgoing message can be seen in here.

By the following steps I will be explaining how to test this behavior if WSO2 ESB.


To Setup :
----------------
  1. Go to <ESB_Home>/samples/axis2Server/src/SimpleStockQuoteService and build it, ant

  2. Start the Go to <ESB_Home>/samples/axis2Server and start the axis2Server by the following command, sh axis2server.sh.

  3. Start the ESB Server, <ESB_Home>/bin by providing, sh wso2server.sh.

  4. Run a tcpMon to view the outgoing messages.

  5. Start the tcpmon in the <ESB_Home>/bin - sh tcpmon.sh
    Create 2 listeners as below. 

    1. Listen Port 8281, Target host – localhost, Target port – 8280 – Before hits the ESB
    2. Listen Port 9001, Target host – localhost, target port – 9000 – After passing through ESB and Before hits the backend
  1. Log in to the ESB and provide the following synapse configuration.


     <?xml version="1.0" encoding="UTF-8"?>  
     <definitions xmlns="http://ws.apache.org/ns/synapse">  
       <sequence name="fault">  
        <log level="full">  
          <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/>  
          <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>  
          <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>  
        </log>  
        <drop/>  
       </sequence>  
       <sequence name="main">  
        <header name="Action" value="urn:getQuote"/>  
        <filter source="get-property('To')" regex=".*/StockQuote.*">  
         <property name="DISABLE_CHUNKING" value="true" scope="axis2"/>  
          <send>  
           <endpoint>  
             <address uri="http://localhost:9001/services/SimpleStockQuoteService"  
                 format="soap11"/>  
           </endpoint>  
          </send>  
          <drop/>  
        </filter>  
        <send/>  
       </sequence>  
     </definitions>  
    

To Send the Rest request :
---------------------------------------------

  1. Go to axis2Client, <ESB_Home>/samples/axis2Client and send the following REST request.
 ant stockquote -Dtrpurl=http://localhost:8281/services/StockQuote -Drest=true  


Observations :
-------------------------
  1. On the server side, Standard :: Stock price = $70.54750695255485 will be generated.
  2. Observe the tcpMon.

Rest request sent to ESB can be seen in port 8281,

Transfer-Encoding: chunked


Outgoing message from ESB can be seen in port 9001,

Content-Length: 275

No comments:

Post a Comment