This sample demonstrates how you can use the ESB to connect to endpoints with WS-Security for outgoing messages.
In this sample the stock quote client sends a request without WS-Security. The ESB is configured to enable WS-Security as per the policy specified in the
policy_3.xml file, for outgoing messages to the SecureStockQuoteService endpoint hosted on the Axis2 instance.
- Download and install the unlimited strength policy files for your JDK before using Apache Rampart (e.g., see http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html).
- For a list of general prerequisites, see Prerequisites to Start the ESB Samples.
Building the sample
The XML configuration for this sample is as follows:
This configuration file
synapse_sample_100.xml is available in the
To build the sample
Start the ESB with the sample 100 configuration. For instructions on starting a sample ESB configuration, see Starting the ESB with a sample configuration.
The operation log keeps running until the server starts, which usually takes several seconds. Wait until the server has fully booted up and displays a message similar to "WSO2 Carbon started in n seconds."
Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Deploy the back-end service
SecureStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.
Executing the sample
The sample client used here is the Stock Quote Client, which can operate in several modes. For further details on this sample client and its operation modes, see Stock Quote Client.
To execute the sample client
Run the following command from the
Analyzing the output
When you analyze the debug log output on the ESB console, you will see the encrypted message flowing to the service and the encrypted response being received by the ESB. You will also see that the
wsse:Security header is removed from the decrypted message and the response is delivered back to the client, as expected.
If you use TCPMon and send the message through it, you will see the message sent by the ESB to the secure service as follows: