The content in this documentation is for older versions of WSO2 products. For updated information on Enterprise Integration Patterns, go to the latest Micro Integrator documentation. "> The content in this documentation is for older versions of WSO2 products. For updated information on Enterprise Integration Patterns, go to the latest Micro Integrator 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

« Previous Version 10 Next »

This section explains, through an example scenario, how the Service Activator EIP can be implemented using WSO2 ESB. The following topics are covered:

Introduction to Service Activator

The Service Activator EIP allows an application to design a service to be invoked both via various messaging technologies and non-messaging techniques. Service Activator interfaces methods and services in the back-end service layer so that the back-end services can be filtered and displayed to the client. For more information, refer to http://www.eaipatterns.com/MessagingAdapter.html.

Figure 1: Service Activator  EIP

Example Scenario for the EIP

This example scenario demonstrates how WSO2 ESB can be used to activate only a specific amounts of services, which are exposed in a back-end Axis2 server. Using the publishWSDL the service WSDL file was modified to filter out only a specific amount of services. The ability of the ESB to create proxy services will allow the client to invoke the ESB proxy instead of invoking the service in Axis2 server.      

Implementing the Example Scenario in WSO2 ESB

Getting Started

The diagram below depicts how to simulate the example scenario using the WSO2 ESB.

 

 

 

Before digging into implementation details, let's take a look at the co-relation of the example scenario and the Service Activator EIP by comparing their core components.

 

Figure 1: Service Activator EIPFigure 2: Service Activator Example Scenario
RequestorSimple Stock Quote Client 
Service ActivatorProxy Service
ReplierSimple Stock Quote Service

 

Environment Setup

1. Download 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 toInstallation Guide in the WSO2 ESB documentation.

2. Start two Sample Axis2 server instances in ports 9001 and 9002. For instructions, refer to section ESB Samples Setup - Starting Sample Back-End Services in the WSO2 ESB Documentation.

ESB Configuration

3. Start the WSO2 ESB and copy the following configuration to the "Source View" in the management console (Main Menu -> Service Bus -> Source View), using which the example scenario can be explored.

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <proxy name="ServiceActivatorProxy" startOnLoad="true">
      <target>
         <endpoint>
            <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
         </endpoint>
         <outSequence>
            <send/>
         </outSequence>
      </target>
      <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>
   </proxy>
   <sequence name="fault">
      <log level="full">
         <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/>
         <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
         <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
      </log>
      <drop/>
   </sequence>
   <sequence name="main">
      <in/>
      <out>
         <send/>
      </out>
   </sequence>
</definitions>

Simulating the Sample Scenario

4. Back end StockQuoteService offers the following services,

  • getFullQuote
  • getMarketActivity
  • getQuote
  • getSimpleQuote
  • placeOrder

But utilizing the publishWSDL feature only some of the back end features will be published through the Service Activator Proxy. browse http://localhost:8280/services/ to view the services offered through the ServiceActivatorProxy the user will be able to notice that apart from services getMarketActivity and getSimpleQuote all the other services are available and active.  

How the Implementation Works

Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration illustrated in step 3 above.

  • Proxy [line 3 in ESB config] - the proxy service defined creates a virtual service between the real back end service and a requestor.
  • publishWSDL [line 12 in ESB config] - by default a proxy service defines a one-to-one mapping of the back end service interface and provides this in form of a WSDL file that requestors can use to connect to the proxy service. By using the publishWSDL mediator, the proxy service can publish a custom interface and in this case the publishWSDL mediator is used to provide access only to a subset of all the service methods available by the back end service. 

 

  • No labels