0
votes

Created a proxy & target inSequence with the below configuration. This proxy should return the response with the content configured in the payload i.e., (<status>01SUCCESS</status>). The response is <status>01SUCCESS</status> in wso2 4.9.0 as is expected. The client used is Apache HTTP Client. But the same does not return the response in wso2 esb 4.8.1 The status is 200 though. In both the cases Java version is 1.7.0_79. Please suggest any solution available for WSO2 ESB 4.8.1?

Proxy:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="buildResponse"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target inSequence="buildResponse" faultSequence="fault"/>
   <description/>
</proxy>

Sequence:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
    <property name="prop" scope="default" type="STRING" value="PROP"/>
    <log>
        <property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
    <payloadFactory media-type="xml">
        <format>
            <status xmlns="">01SUCCESS</status>
        </format>
    </payloadFactory>
    <log>
        <property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
    </log>
    <header action="remove" name="To" scope="default"/>
    <property name="RESPONSE" scope="default" type="STRING" value="true"/>
    <send/>
</sequence>
2

2 Answers

0
votes

If your request is a GET of DELETE, you need to remove NO_ENTITY_BODY before send mediator : <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>

0
votes

If request is HTTP POST, this property is required in the sequence, even if we include for HTTP GET request does not have any issue.

<property name="messageType" value="text/xml" scope="axis2" type="STRING"/>

Below sequence configuration will work for both HTTP GET and POST requests; since property required for POST request is also included in the configuration.

 <?xml version="1.0" encoding="UTF-8"?>
    <sequence name="buildResponse" xmlns="http://ws.apache.org/ns/synapse">
        <property name="prop" scope="default" type="STRING" value="PROP"/>
        <log>
            <property expression="get-property('prop')" name="prop" xmlns:ns="http://org.apache.synapse/xsd"/>
        </log>
        <payloadFactory media-type="xml">
            <format>
                <status xmlns="">01SUCCESS</status>
            </format>
        </payloadFactory>
        <log>
            <property expression="$body" name="body" xmlns:ns="http://org.apache.synapse/xsd"/>
        </log>
        <property name="messageType" value="text/xml" scope="axis2" type="STRING"/>
       <property name="NO_ENTITY_BODY" scope="axis2" action="remove"/>

        <header action="remove" name="To" scope="default"/>
        <property name="RESPONSE" scope="default" type="STRING" value="true"/>
        <send/>
    </sequence>