This section explains, through an example scenario, how the Messaging Gateway EIP can be implemented using WSO2 ESB. The following topics are covered: Table of Contents
...
The Messaging Gateway EIP encapsulates message-specific code from the rest of the application. It is a class than that wraps messaging-specific method calls and exposes domain-specific methods to the application. Only the Messaging Gateway knows about the actual implementation of the messaging system. Rest The rest of the application calls the methods of the Messaging Gateway, which are exposed to the outside worldexternal applications. For more information, refer to http://www.eaipatterns.com/MessagingGateway.html.
...
Proxy services in WSO2 ESB act as Messaging Gateways, abstracting away the details of the actual back-end services from implementing clients. For a more complex example of how the WSO2 ESB can act as a Messaging Gateway, refer to Health Care Scenario where , where a single Proxy Service acts as a Messaging Gateway between several back-end services.
...
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Messaging Gateway EIP by comparing their core components.
Figure 1: Messaging Gateway EIP Figure 2: (Figure 1) | Messaging Gateway Example Scenario (Figure 2) |
---|---|
Application | Simple Stock Quote Client / Service |
Messaging Gateway | Proxy Service |
Environment setup
- Download an and install the WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Getting Started Installation Guide in the WSO2 ESB documentation.
- Start the sample Axis2 server. For instructions, refer to the section Setting Up the ESB Samples Setup - Starting Sample Back-End Servicesthe Axis2 server in the WSO2 ESB documentation.
- Copy the sample_proxy_3.wsdl file in tointo your
<ESB_HOME>
/repository/samples/resources/proxy
directory.
...
Start the ESB server and log into its management console UI (https:
//localhost:9443/carbon
). In the management console, navigate to the Main Menu, click Service Bus and then Source View menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.
Anchor | ||||
---|---|---|---|---|
|
...
Simulating the sample scenario
If you navigate to http://localhost:9000/services/SimpleStockQuoteService
, you can see the WSDL file of the back-end server. There are five methods exposed
...
externally, but the Proxy Service SimpleQuoteProxy
exposes only four
...
externally, filtering out the getFullQuote
method. See the SimpleQuoteProxy
WSDL file in http://localhost:8280/services/StockQuoteProxy?wsdl
.
Send the following request using a SOAP client like SOAP UI SoapUI to the SimpleQuoteProxy
service.
...
After sending the above message to the server, you'll get a server error as 'The endpoint reference (EPR) for the Operation not found is /services/StockQuoteProxy and the WSA Action = urn:getFullQuote. ' The reason for this error is because that the getFullQuote
method is not exposed to SimpleQuoteProxy
, although the back-end server supports it.
Now, change the publish specify a different published WSDL file as follows and send the same SOAP message to the server again.
...
Note that you get the correct response from the server, since the new WSDL of the proxy service is the same as the back-end service.
...
Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration illustrated in step 4 shown above.
- proxy [line 2 in ESB config] - Defines a new Proxy Service proxy service called
StockQuoteProxy
. - endpoint [line 4 in ESB config] - The endpoint mediator defines Defines the endpoint of the actual back-end service that this proxy service is connected to. That is, the actual back-end service address.
- publishWSDL [line 11 in ESB config] - The
publishWSDL
mediator defines Defines the WSDL file to expose for this proxy service. If nopublishWSDL
is given, the actual back-end service's WSDL is exposed.