Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The ESB sends messages to services at designated endpoints. A proxy service acts as a virtual front end to a service, allowing you to intercept and 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 are sent back to 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 lesson walks you through the following tasks:

Configure the sample
Anchor
ConfigSample2
ConfigSample2

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

2. Click "Main -> Proxy Service". In this task, you create the proxy service and endpoint that will be used to connect to the service.

To configure the sample:

  1. On the Main tab in the Management Console, click Proxy Service.
    There are several templates available for creating a proxy service.

...

  1. Image Modified

...

  1. Click Custom Proxy

...

  1. .
    The proxy service creation wizard appears.
    custom proxy service setupImage Modified

...

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

...

...

  1. In the

...

  1. Publishing WSDL

...

  1. drop-down list, select

...

  1. Specify Source URL

...

  1. , enter the URL of the WSDL as file:repository/samples/resources/proxy/sample_proxy_1.wsdl, and then click

...

  1. Test URI

...

  1. to validate the path.
    In the future, you can determine the WSDL of a running service using the ?wsdl operation.
    Publish WSDLImage Modified

...

  1. Select the transports needed to expose the proxy service in the

...

  1. Transport Settings

...

  1. 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 settingsImage Modified
    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.

...

  1. Click Next

...

  1. .
    You will now add a target endpoint

...

  1. to handle request messages.

...

  1. Under Define Endpoint, click

...

  1. Define Inline

...

  1. , and then click the

...

  1. Create

...

  1. button that appears.

...

  1. In sequence and endpoint optionsImage Modified

...

  1. Click Address Endpoint

...

  1. .
    This will allow us to configure the endpoint by typing the URL of the service.
    Address endpointImage Modified

...

  1. Type the EPR of the target endpoint in the Address field as

...

  1. http://localhost:9000/services/SimpleStockQuoteService

...

  1. , leave the other fields unchanged, and click

...

  1. Save

...

  1. to add the endpoint to the proxy service.
    Configure address endpointImage Modified

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

...

  1. Back in the Step 2 screen, leave the In sequence empty and click Next.
    You will now add an Out sequence that will send the response messages back to the client.
  2. Under Define Out Sequence, click

...

  1. Define Inline

...

  1. , and then click the

...

  1. Create

...

  1. button that appears.
    define out sequenceImage Modified

...

  1. In the sequence editor,

...

  1. add the send mediator by clicking Add Child -> Core -> Send

...

  1. .
    Sequence editorImage Modified

...

  1. Click

...

  1. Save

...

  1. , and then click

...

  1. Finish

...

  1. to save and quit the wizard.

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

...

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

Start the server
Anchor
StartServer2
StartServer2

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:

...

Now that the server is running, let's run the client and send a request to the service. Go to the <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 stock quote request directly to the provided transport endpoint at: (http://localhost:8280/services/StockQuoteProxy). The proxy service receives the message and uses the send mediator to forward it to the server. The response from the server is displayed in the console as follows:

 

...

Standard :: Stock price = $165.32687331383468

You have now learned how to create a proxy service that intercepts messages and uses mediators to manipulate the messages before sending them to the server. In the next lesson, you will learn how to monitor the mediation and the ESB.