Monday, December 12, 2011

How to write a proxy to filter soap 1.1 requests with WSO2 ESB

Download WSO2 ESB and start the server.

We will be using SimpleStockQuoteService  service. So go to wso2esb-4.0.3/samples/axis2Server/src/SimpleStockQuoteService and type 'ant' in order to build.

Go to wso2esb-4.0.3/samples/axis2Server and type ./axis2server.sh.

Use admin/admin as username and password.

Select source view (Under service bus tab).

Use the following code for proxy. (Paste the code above the <definitions> tag)


<proxy name="DummyProxy" transports="https http" startOnLoad="true" trace="disable">
        <target>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
            <inSequence>
                <log level="full"/>
                <filter xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xpath="/soapenv:Envelope ">
                    <then>
                        <log level="custom">
                            <property name="MSG_FLOW" value="soap 1.1 success!!!"/>
                        </log>
                    </then>
                    <else/>
                </filter>
            </inSequence>
            <outSequence>
                <send/>
            </outSequence>
        </target>
    </proxy>


Click update.

Click list option under Web services. You will be able to see the proxy which you created. (DummyProxy).

The relevant wsdl is generated and it can be accessed from http://localhost:8280/services/DummyProxy?wsdl

Using soapUI to test the proxy service.

Create a new soapUI project and provide the wsdl of the SimpleStockQuoteService
http://localhost:9000/services/SimpleStockQuoteService?wsdl



Edit the current endpoint as http://localhost:8280/services/DummyProxy


Use the following soap request


<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ser="http://services.samples">
   <soap:Header/>
   <soap:Body>
      <ser:getSimpleQuote>
         <!--Optional:-->
         <ser:symbol>Apple</ser:symbol>
      </ser:getSimpleQuote>
   </soap:Body>
</soap:Envelope>


(replace "?" with "Apple" )


Try with soap 1.1 and soap 1.2 using soapUI.

Using soap 1.1 - You can see the following output


Using soap 1.2 - You cannot see the above message as this proxy filters soap 1.1 an drops others.





No comments:

Post a Comment

Using Zotero for academic writing