This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

The ESB sends messages to services at designated endpoints. A proxy service acts as a virtual front end to a service, allowing you to mediate messages destined for that service. This service mediation can include adding WS-Security, exposing the message on a different transport, transforming the message, and more. It can mediate the messages before they are delivered to the actual endpoint, and it can mediate the response messages before they reach the client.

When a client sends a request to a service at a specific endpoint, the ESB uses the proxy service for that service to perform the service mediation. The most common service mediation is to process the message and send it to the actual service, which is usually running on a different computer. However, it is not necessary to always send the message to the actual service. You can list any combination of tasks to be performed on the messages received by the proxy service and could terminate the flow or send a message back to the client without sending it to the actual service.

Let's explore a simple proxy service scenario that illustrates service mediation. This sample walks you through the following tasks:

Configure the sample

1. If you have not already done so, set up the ESB and start the management console before proceeding.

2. Click "Main -> Proxy Service". There are several templates available for creating a proxy service.

3. Select the "Custom Proxy" template. The proxy service creation wizard appears.

custom proxy service setup

4. For the proxy service name, enter "StockQuoteProxy". 

5. In the "Publishing WSDL" drop-down list, select "Specify Source URL", enter the URL of the WSDL as file:repository/samples/resources/proxy/sample_proxy_1.wsdl, and then click "Test URI" to validate the path. In the future, you can determine the WSDL of a running service using the ?wsdl operation.

Publish WSDL

6. Select the transports needed to expose the proxy service in the "Transport Settings" panel at the bottom of the page. For this example, leave the defaults set to make this proxy service available on both HTTP and HTTPS.

Transport settings

Note that you can also add service parameters to the proxy service. When the ESB starts, it initiates all proxy services that may need to fetch WSDLs associated with proxy services. If the ESB cannot locate those WSDLs during startup, it ignores them and continues.

7. Click Next, and then add a target endpoint to handle request messages and a target 'in' sequence to handle request messages. To add a target endpoint, click "Define Inline" under "Define Endpoint" and click the "Create" button that appears.

In sequence and endpoint options

8. In the list that opens, select "Address Endpoint". This will allow us to configure the endpoint by typing the URL of the service.

Address endpoint

9. Type the EPR of the target endpoint in the Address field as "http://localhost:9000/services/SimpleStockQuoteService", leave the other fields unchanged, and click "Save" to add the endpoint to the proxy service.

Configure address endpoint

10. You will be navigated back to the previous screen. Click "Next" leaving the 'In' Sequence empty.

11. Next, to add an 'out' sequence that will send the response messages back to the client, click "Define Inline" under "Define Out Sequence" and click the "Create" button that appears.

define out sequence

12. In the sequence editor, click the "Add Child" icon, and then click "Core -> Send" from the sub menus to create a send mediator with default configuration.

Sequence editor

13. Click "Save", and then click "Finish" to save and quit the wizard.

14. The newly created proxy service appears in the "deployed services" list. Click its name to view its dashboard.

Proxy service dashboard

You have finished configuring the sample scenario and are ready to test and monitor the mediation.

Start the server

You already built and deployed the SimpleStockQuote service, so simply start the server by switching to the <PRODUCT_HOME>/samples/axis2Server directory and running one of the following commands:

  • Linux / Unix: ./axis2server.sh
  • Windows: axis2server.bat

Run the client

Now that the server is running, let's run the client and send a request to the service. Go to <PRODUCT_HOME>/samples/axis2Clients directory and type the following command:

 

ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuoteProxy -Dmode=quote -Dsymbol=IBM

This command sends a stockquote request directly to the provided transport endpoint at: http://localhost:8280/services/StockQuoteProxy. The response from the server is displayed in the console as follows:

 

Standard :: Stock price = $165.32687331383468
  • No labels