WSO2 ESB provides the following property mediator to remove the "Chunked" encoding type when calling SOAP endpoints. You can use the below configuration to call a SOAP endpoint which expects a non-chunked request (Request with "Content-Length" header).
<property name=”DISABLE_CHUNKING” value=”true” scope=”axis2″/>
Here is a sample proxy service configuration.
<?xml version=”1.0″ encoding=”UTF-8″?>
<proxy xmlns=”http://ws.apache.org/ns/synapse”
name=”SampleProxy_v1″
transports=”https”
startOnLoad=”true”
trace=”enable”>
<description/>
<target>
<inSequence>
<property name=”DISABLE_CHUNKING” value=”true” scope=”axis2″/>
<send>
<endpoint>
<address uri="http://localhost:9764/services/HelloService" ></address>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<publishWSDL uri=”http://192.168.66.1:9764/services/HelloService?wsdl”/>
</proxy>
If you need to call a REST endpoint without the "chunked" encoding, sometimes the above property mediator would not work. In that kind of situation, if you need to send "Content-Length" header which means "non-chunked" request, you can use the following 2 properties.
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
Here is a sample API definition for WSO2 ESB.
<api xmlns="http://ws.apache.org/ns/synapse" name="SampleAPI" context="test">
<resource methods="POST" url-mapping="/*">
<inSequence>
<log level="custom">
<property name="msg" value="Executing IN sequence"></property>
</log>
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
<send>
<endpoint>
<address uri="https://www.google.com" format="rest"></address>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="msg" value="Sending response"></property>
</log>
<send></send>
</outSequence>
<faultSequence>
<log level="custom">
<property name="msg" value="Error occurred "></property>
</log>
<send></send>
</faultSequence>
</resource>
</api>
<property name=”DISABLE_CHUNKING” value=”true” scope=”axis2″/>
Here is a sample proxy service configuration.
<?xml version=”1.0″ encoding=”UTF-8″?>
<proxy xmlns=”http://ws.apache.org/ns/synapse”
name=”SampleProxy_v1″
transports=”https”
startOnLoad=”true”
trace=”enable”>
<description/>
<target>
<inSequence>
<property name=”DISABLE_CHUNKING” value=”true” scope=”axis2″/>
<send>
<endpoint>
<address uri="http://localhost:9764/services/HelloService" ></address>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence/>
</target>
<publishWSDL uri=”http://192.168.66.1:9764/services/HelloService?wsdl”/>
</proxy>
If you need to call a REST endpoint without the "chunked" encoding, sometimes the above property mediator would not work. In that kind of situation, if you need to send "Content-Length" header which means "non-chunked" request, you can use the following 2 properties.
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
Here is a sample API definition for WSO2 ESB.
<api xmlns="http://ws.apache.org/ns/synapse" name="SampleAPI" context="test">
<resource methods="POST" url-mapping="/*">
<inSequence>
<log level="custom">
<property name="msg" value="Executing IN sequence"></property>
</log>
<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>
<send>
<endpoint>
<address uri="https://www.google.com" format="rest"></address>
</endpoint>
</send>
</inSequence>
<outSequence>
<log level="custom">
<property name="msg" value="Sending response"></property>
</log>
<send></send>
</outSequence>
<faultSequence>
<log level="custom">
<property name="msg" value="Error occurred "></property>
</log>
<send></send>
</faultSequence>
</resource>
</api>
Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updating mulesoft online training Hyderabad
ReplyDelete