fb
WSO2 5 minutes

Working with samples in Integration Studio

Rob Blaauboer
Rob Blaauboer
Integration Consultant & WSO2 Trainer
Blog Sampling in WSO2
Scroll

In a previous blog, we discussed the samples that are included with the Enterprise Integrator. Now, we’re going to look at the samples that are part of the Getting Started functionality of Integration Studio. What is the benefit for using these samples over the ones within the product? That is what we are going to answer in this blog.

Samples Integration Studio 1

As you can see from the screenshot, there are several samples available. This allows you to do error handling, working with Docker, JMS, unit testing message transformation, and so on.

So, what happens if you click on one of these icons? Let’s take a Hello World as an example. Why this one? Simply because Hello World is often the starting point, a simple sample to get started.

Samples Integration Studio 2

Let’s start with the Hello World Service. It instantly starts the process of creating a project in Integration Studio. Within that project, we have a composite exporter, to make sure that the car file is deployed to the Enterprise integrator. It has an API called Hello World API, which consists of a very simple payload factory in the response mediator. And it also shows you how to work with this example.

The benefit is that we do not have to be bothered with creating a project. Not that creating a project is such a big thing, but I can imagine that if you’re new to Integration Studio and/or Enterprise Service Bus technology, this can help you. In the previous blog about samples, I described how to create a project like this.

Samples Integration Studio 3

As you can see the API is quite simple. 

Samples Integration Studio 4

The graphical overview shows the high-level flow. If we want to know more, we need to switch to the source view.

Samples Integration Studio 5

Again, the source view shows a JSON response with the famous Hello World and then the response is given back to the client.

Samples Integration Studio 6

If you want to run this on the enterprise integrator, you need to have one installed first. In general, it’s installing JDK 8 or 11, setting Java_home, adding the Java installation to the path and unzipping the WSO2 product in a directory. 

Integration Studio for launching enterprise integrator 

Integration studio can be used to launch a version of the enterprise integrator. The benefit of this setup is that you have the console messages in the same environment as the development tools. 

The samples within Integration Studio also describe how to run it in such an environment. After the installation that I just described, you can use the ‘add server’ button in the getting started tab to add a server to the configuration.

Samples Integration Studio 7

You simply select the version of the Enterprise Integrator, click on the next button and fill in the location where the Enterprise Integrator is installed. In this case it is installed on Windows on the desktop in a subdirectory. Pointing to this directory, make sure that Integration Studio knows where to find the configurations that it needs for starting the product. 

Samples Integration Studio 8

After doing this, you can see that the server is now available. However, the server is in a different tab than the properties and console tabs, which I personally find unpractical. Go to the server tab, click and hold the left mouse button to drag the server tab on the properties console and HTTP client at the bottom of the screen. Right click on the Enterprise Integrator server and select start. It should switch to the console if it doesn’t happen automatically already, to see the information being displayed about the startup procedure. WSO2 products will output log information that’ll tell you whether the installation is successful, or not!

Samples Integration Studio 9

When you see the management URL being displayed on the console, you know that the product is now ready to be used. Unless you changed the start procedure it will also open a browser window to the management URL, allowing you to log in to the product.

Samples Integration Studio 10

The admin credentials allow you to log in as the product superuser. With these credentials you can manipulate almost every aspect of the product. Keep in mind that this is an out of the box installation that uses a self-signed and standard keystore and of course needs to be changed as well as the password of the admin user, because of the aforementioned superpowers the admin has.

Samples Integration Studio 11

We now need to add the composite exporter, or rather the car file underneath it to the Enterprise Integrator. This is done, amongst others, by add and remove, a context aware option available by right clicking on the Enterprise Integrator 6.6.0.

If everything goes well, and why shouldn’t it, you will now see a message on the console that the API has been deployed.

[2021-06-28 13:21:33,889]  INFO {org.wso2.carbon.mediation.dependency.mgt.DependencyTracker} - API : HelloWorld was added to the Synapse configuration successfully - [ Deployed From Artifact Container: MyProjectCompositeExporter ] 
[2021-06-28 13:21:33,890]  INFO {org.apache.synapse.deployers.APIDeployer} - API named 'HelloWorld' has been deployed from file : C:UsersrobDesktopWSO2wso2ei-6.6.0tmpcarbonapps-12341624879293853MyProjectCompositeExporter_1.0.0-SNAPSHOT.carHelloWorld_1.0.0HelloWorld-1.0.0.xml
[2021-06-28 13:21:33,891]  INFO {org.wso2.carbon.application.deployer.internal.ApplicationManager} - Successfully Deployed Carbon Application : MyProjectCompositeExporter_1.0.0-SNAPSHOT {super-tenant}

This means that the API is now available to be used and we can invoke it in a number of ways. We can use Soap UI, Postman, Advanced Rest Client, Curl or even a simple browser. The reason why we can use a browser is that we’re doing a get which retrieves information and does not require a payload to be sent. Since there are also no parameters defined in this API if we type in http://localhost:8280/HelloWorld

Samples Integration Studio 12

We can see the response in JSON in the browser. Clicking on raw data and headers gives more information about the API invocation.

Conclusion

There are several samples included in the Integration Studio environment that are easy to use and do not require that much knowledge of Enterprise Integrator and/or Integration Studio. Therefore, it is ideally suited for novice users and although the example shown above is very simple, the other examples are more elaborate and can help you understand the principle and perhaps help you adopt it to your needs.