5 Nisan 2013 Cuma

WSO2 ESB: Simple Sequence To Send A Static XML Response

Aim

Sometimes we meet some requests coming to ESB which have to be responded by a pre-defined XML, or an XML which is created easily in a dynamic way on the fly. In a such case we don't want to call a web service. We want to send our response back directly without need to a pinp-pong wall like echo service (as in my previous approach).



Sample Sequence (gist here)

<sequence xmlns="http://ws.apache.org/ns/synapse" name="main" trace="disable">
    <in>
        <log level="headers">
            <property name="?" value="[main] in: started"/>
            <property name="To" expression="get-property('To')"/>
            <property name="PAYLOAD" expression="/*"/>
        </log>
        <script language="js"><![CDATA[
            mc.setPayloadXML(<greeting>Hello World</greeting>);
        ]]></script>
        <header name="To" action="remove"/>
        <property name="NO_ENTITY_BODY" action="remove" scope="axis2"/>
        <property name="RESPONSE" value="true"/>
        <send/>
        <log level="headers">
            <property name="?" value="[main] in: ended"/>
            <property name="PAYLOAD" expression="/*"/>
        </log>
    </in>
    <out>
        <log level="headers">
            <property name="?" value="[main] out: started"/>
            <property name="RESPONSE" expression="/*"/>
        </log>
        <send/>
        <log level="headers">
            <property name="?" value="[main] out: ended"/>
        </log>
    </out>
</sequence>

Sample Response

Practical Usage Scenario

ClientAccesPolicy.xml and CrossDomain.xml. I will write about them at next post.





Hiç yorum yok:

WSO2 ESB + ClientAccesPolicy.xml + CrossDomain.xml

ClientAccesPolicy.xml and CrossDomain.xml files have to be found at root of your services Silverlight and Flex clients to be able to acce...