fb
WSO2 Enterprise Integrator 8 minutes

Working with samples in the WSO2 Enterprise Integrator

Rob Blaauboer
Rob Blaauboer
Integration Consultant & WSO2 Trainer
Ontwerp zonder titel
Scroll

There is an old saying that goes: “Don’t reinvent the wheel”. This means that you do not have to invent something that already exists. When you start working with WSO2 Enterprise Integrator, this is exactly what you need to keep in mind. The Enterprise integrator comes with a large number of examples for both the ESB functionality, but also the other products that are bundled with it such as the Business Processor.

Samples galore

In a blog that I previously wrote about Enterprise Integration Patterns, we also saw that these are accompanied by examples on the WSO2 Enterprise Integrator. 

However, these Enterprise Integration samples are, I would say, standardized use cases that all organizations would typically encounter. For example, content-based routing and the dead letter channel. Those are very familiar patterns for anyone working in the integration space. The samples that are bundled with the products are, in some cases, very specific. Whereas the Enterprise Integration patterns are, of course, more generic. However, there is a dedicated part of the documentation of WSO2 that will take the generic pattern and translate it to a specific WSO2 setup. 

But there is more! The samples that show the capabilities of the ESB. These are part of the downloaded zip and can be found in the /samples subdirectory.

WSO2 Enterprise Integrator samples 1

It is also good to emphasize that these are examples, and that you can adopt these, or change them, or tweak them to your liking. As I often say, there is always another way of doing things. And that is also true for the samples in this blog. 

WSO2 Micro Integrator instead of Enterprise Integrator?

I am going to show you how you work with these examples on the Enterprise Integrator. Why not the Micro Integrator? The Micro Integrator is also a little bit different, although it uses the same technology. Micro integrator is a slimmed down version of the enterprise integrator, lacking additional things, like the Message Broker and the Business Process server. And it does not have a management UI like enterprise integrators do. So, it should be considered as a different product. And the samples are also not there. So, if you are looking to use samples using a Micro Integrator, basically just download the Enterprise Integrator and take a look at the samples. 

In order to use the samples, we need to deploy them to the Enterprise Integrator. In previous versions of the Enterprise Integrator, we could simply start the product in a sample configuration, but the current version (6.6.0) does not have that capability. 

What do we need?

So, what do we need to do? Well, I am using Integration Studio as the way to work with these examples. The samples also come with clients that you need to build using Apache Ant. This is a build tool for Java applications, like Maven. There is also a standalone Axis2Server in the samples. Apache Axis2™ is a Web Services / SOAP / WSDL engine used in the WSO2 Enterprise Integrator. Download Ant from the Apache website. Install it on your pc in a subdirectory and make sure you add the location to the path so you can invoke ant from anywhere.

WSO2 Enterprise Integrator samples 2

We will focus on samples that we can use with Integration Studio and WSO2 Enterprise Integrator.

If you are not sure how to install these two products, please look at previous blogs that are written about installing WSO2 Products.

In general, you just need Java versions 8 or 11 or OpenJDK or any other new supported version. You can find the full list here: https://docs.wso2.com/display/compatibility/Tested+Operating+Systems+and+JDKs

As far as working with the WSO2 Enterprise Integrator, you can download the zip file from the GitHub repository. Keep an eye on the license that you are using, the version that you download from the WSO2 site is the one with the EULA license and can not be used in production without a license, but it can be used to try something out like in this blog.

WSO2 Enterprise Integrator samples 3

A directory on the desktop with WSO2 Enterprise Integrator and Integration Studio 8. Open the Integration Studio directory and click on the Integration Studio Application icon. 

WSO2 Enterprise Integrator samples 4

Take the default workspace if this is your first time with the product, or create your own workspace.

WSO2 Enterprise Integrator samples 5

After Starting, click on the icon that looks like a bunch of grapes.

WSO2 Enterprise Integrator samples 6

It now switches to the mode for working with ESB Graphical Mode.

WSO2 Enterprise Integrator samples 7

First, we add an WSO2 Enterprise Integrator 6.6.0 Server. Click on Window in the menu. 

WSO2 Enterprise Integrator samples 8

Then on Show View and Other.

WSO2 Enterprise Integrator samples 9

Click on open and the server tab appears. Drag the Server tab to the Window below Getting Started.

WSO2 Enterprise Integrator samples 10

Right Click on an empty space in the Server and Select New Server.

WSO2 Enterprise Integrator samples 11

Select 6.6.0.

WSO2 Enterprise Integrator samples 12

And Click Next. Point to the location where WSO2 Enterprise Integrator is installed, in my case:

WSO2 Enterprise Integrator samples 13

Click Finish. The server is now added.

Creating a project

The sample that I am going to use is Sample 150: Introduction to Proxy Services. The code is simple:

<definitions xmlns="http://ws.apache.org/ns/synapse">
    <proxy name="StockQuoteProxy">
        <target>
            <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
            <outSequence>
                <send/>
            </outSequence>
        </target>
        <publishWSDL uri="file:samples/service-bus/resources/proxy/sample_proxy_1.wsdl"/>
    </proxy>
</definitions>

In order to create this artifact, I am going to create a proxy as defined above in an integration project and deploy it to the WSO2 Enterprise Integrator. The Definitions overview is taken from the ESB Source view, which shows the entire deployment on the system. However, this is read-only, in other words, we cannot change the setup, other than by deploying artifacts via a CAR file.

Create an Integration Project like below and click Finish. 

WSO2 Enterprise Integrator samples 14

Create a new proxy with the custom proxy template. 

WSO2 Enterprise Integrator samples 15

Use the name StockQuoteProxy and click Finish.

WSO2 Enterprise Integrator samples 16

Switch to source code and copy the <target> definition into the view. Switch to Graphical view and back to source to see the following screen.

WSO2 Enterprise Integrator samples 17

Press CTRL + S to Save. Go to the CompositeExporter and Select the Proxy you just created. Use CTRL + S to Save.

WSO2 Enterprise Integrator samples 18
WSO2 Enterprise Integrator samples 19

When started, add the Car file to the Server. 

WSO2 Enterprise Integrator samples 20

Everything is now deployed. You can see in the log files that this is true.

[2021-06-25 12:37:03,917]  INFO {org.wso2.carbon.application.deployer.internal.ApplicationManager} - Deploying Carbon Application : SampleProjectCompositeExporter_1.0.0-SNAPSHOT.car...
[2021-06-25 12:37:05,242]  INFO {org.wso2.carbon.mediation.dependency.mgt.DependencyTracker} - Proxy service : StockQuoteProxy was added to the Synapse configuration successfully - [ Deployed From Artifact Container: SampleProjectCompositeExporter ] 
[2021-06-25 12:37:05,242]  INFO {org.apache.synapse.core.axis2.ProxyService} - Building Axis service for Proxy service : StockQuoteProxy
[2021-06-25 12:37:05,267]  INFO {org.apache.synapse.core.axis2.ProxyService} - Adding service StockQuoteProxy to the Axis2 configuration
[2021-06-25 12:37:05,271]  INFO {org.wso2.carbon.core.deployment.DeploymentInterceptor} - Deploying Axis2 service: StockQuoteProxy {super-tenant}
[2021-06-25 12:37:05,271]  INFO {org.apache.synapse.core.axis2.ProxyService} - Successfully created the Axis2 service for Proxy service : StockQuoteProxy
[2021-06-25 12:37:05,271]  INFO {org.apache.synapse.deployers.ProxyServiceDeployer} - ProxyService named 'StockQuoteProxy' has been deployed from file : C:UsersrobDesktopsamplesEIwso2ei-6.6.0tmpcarbonapps-12341624617423923SampleProjectCompositeExporter_1.0.0-SNAPSHOT.carStockQuoteProxy_1.0.0StockQuoteProxy-1.0.0.xml
[2021-06-25 12:37:05,271]  INFO {org.wso2.carbon.application.deployer.internal.ApplicationManager} - Successfully Deployed Carbon Application : SampleProjectCompositeExporter_1.0.0-SNAPSHOT {super-tenant}

Building the service

Traverse to the samplesaxis2ServersrcSimpleStockQuoteService directory and build the service using the command ant.

WSO2 Enterprise Integrator samples 21

The (axis2) service, an .aar file, is now stored in the repository subdirectory. When you start the axis2 server, the .aar file will be deployed. Try it with the command axis2server.bat (or .sh for Linux)

WSO2 Enterprise Integrator samples 22

Executing the service

Now it is time to execute the service. I am going to use SoapUI as a client rather than the ant stockquote client as I know the message that we can send, and I already have it installed. 

The ant client needs some modification in order to compile and it also shows a lot of debug statements that I really do not need. So SoapUI is a better option. 

WSO2 Enterprise Integrator samples 23

Take the url of the WSDL from the Management UI of the Enterprise Integrator, by clicking on the icon and in the browser copying the address. If something else is shown then localhost, you can use that or replace it. This of course if you are running on localhost i.e., on your local machine with an Out Of The Box WSO2 Enterprise Integrator (no changes made to the config of hostname).

WSO2 Enterprise Integrator samples 24

In SoapUI, create a new Soap project, and copy the WSDL in the Initial WSDL field. Click OK.

WSO2 Enterprise Integrator samples 25

Select getQuote from the options.

WSO2 Enterprise Integrator samples 26

Fill in IBM at the ? and press the Green triangle. See the response coming back.

WSO2 Enterprise Integrator samples 27

Conclusion 

The samples in the WSO2 Enterprise Integrator are helpful in understanding concepts of the product, however, they do require some work in order to deploy and test them. In a next blog, I will look into the samples that are part of Integration Studio, one of the development environments that can be used in conjunction with the WSO2 Enterprise Integrator.

Learn more about WSO2 Enterprise Integrator 

I hope you enjoyed reading this blog. If you are interested in learning more about the WSO2 Enterprise Integrator, why don’t you have a look at the WSO2 training we offer? As of October 2021, we are starting with our instructor lead face to face trainings in The Netherlands, United States and in company trainings at your office or a training venue near for groups of trainees from one organization.