Wednesday, April 29, 2015

[WSO2 ESB] Java client to invoke secured(UsernameToken) proxy service

1. Download the latest version of WSO2 ESB and deploy  this proxy service.(You can copy this file to to wso2esb-4.8.1/repository/deployment/server/synapse-configs/default/proxy-services directory)

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns=""
                    <address uri="https://localhost:9002/services/SimpleStockQuoteService"/>
            <header xmlns:wsse=""

2. Start the ESB  server.

3. Go to the wso2esb-4.8.1/samples/axis2Server/src/SimpleStockQuoteService and execute the ant command . That will build the SimpleStockQuoteService.aar and copy in to deployment directory of the  simple axis2 server.

4. Go to the wso2esb-4.8.1/samples/axis2Server and start the simple axis2 server(sh

5. The service endpoint  of SimpleStockQuoteService will be https://localhost:9002/services/SimpleStockQuoteService .

6. Login to the ESB management console and upload this policy to  registry. (/_system/config/repository/components/

7. Go to the service list and start to secure the SimpleStockQuoteServiceProxy.

8. Check the UsernameToken option and pick the policy.xml from registry.

9. Select the user roles that proxy service can invoke.

10.Execute the ant command inside wso2esb-4.8.1/bin and set the wso2esb-4.8.1/lib as the class path of the project.

11. Copy the policy.xml to ESB home directory that path used in in  StockQuoteSecureClient.

12. Update the carbon_home and proxyEndpoint in StockQuoteSecureClient class and execute the client .