ESB Proxy Service Sample
Carbon Studio can be used effecetively to work with WSO2 Enterprice Service Bus (ESB) for visual editing of Sequence definitions, Endpoint definitions, Proxy service definitions as well as whole Synapse configurations. In this guide we will show you, how you can use Carbon Studio IDE to do the ESB Proxy Service example.
Creating a Carbon Application ProjectTo create a Carbon Application Project (CApp), right click on the Project Explorer and select New => Other from the menu or Select File => New => Other . You can also click the New button on the toolbar.
Select Carbon Application Project and select Next
Type a name for your Project and click on Finish.
If you have successfully completed the project creation process, your Carbon Studio will look like similar to this.
Creating a Proxy Service using Carbon Studio IDE
Here, we are going go create a Proxy Service using Carbon Studio. Proxy Service is one of the Artifacts that can be deployed on ESB. You can add Artifacts to your CApp project by selecting New => Proxy Service from the Right click menu.
You can add Proxy Service File => New => Other => Proxy Service menu as well. If you follow that procedure, you will get a dialog box as shown in the following image.
Select Next and you will be forwarded to the next step. For both approaches described above, this step is same. Both approaches will bring you to this step. Provide a name for your Proxy Service for Name. For this example, specify the Proxy Service name as StockQuoteProxy. Select the New Proxy Service option from the option list and select Custom Proxy from the Drop Down List as shown in the image below. Finally Click Next.
You do not need to change any default settings in this dialog box. Click on Finish.
You have just added a Proxy Service with default configuration to your CApp project. If you have successfully followed the steps, you will get a CApp project as shown in the image below.
Now we move on to configure the Proxy Service you have just added to your CApp project. First, Open StockQuoteProxy.xml by either double clicking on the StockQuoteProxy.xml file or selecting Open With => ESB Editor from right click menu. ESB Editor is a sophosticated Editor provided by WSO2 to edit ESB Artifacts including Proxy Services, Sequences, etc. You will see the ESB editor as shown in the image below.
In order to configure the added Proxy Service, we use the Properties View. You can open the Properties View by either double clicking on the Items on the ESB Editor or selecting Window => Show View => Properties. If you select the Root Element on the ESB Editor, you will see a set of configurable properties as shown in the image below. You can add/remove/chnage the Transports for your Proxy Service from there. You can enable Tracing and Statistics from there. If you need to change the QoS properties such as Enabling Security and Reliable Messaging, you can change them from there. As discussed in the original example, we won't need to change any of the default settings shown for the Root element.
For a Proxy Service it requires a WSDL. Therefore, we first set the WDSL settings for the Proxy Service. Select WSDL in the ESB Editor. You will notice that the properties view will be changed when you select the WSDL. For the WSDL Type property, select Specify Source URL option from the dropdown list in the properties view.
When you setlect Specify Source URL at WSDL Type, another new property will appear in the Properties View as WSDL URL. You can point to a WSDL in URI format here. It can be either a file in the file system or a http url. For this example, we use a WSDL file stored in the file system. Therefore set file:repository/samples/resources/proxy/sample_proxy_1.wsdl as the WSDL URL.
Now you have successfully configured the WSDL and now we move on to configure the EndPoint. As explained in the original example, here we use an Address End point. In default configuration, there are no end points related to a Proxy Service . Therefore we manually add an address end point by selecting New Child => End Point[Address](Anonymous) from the right click menu of the Endpoint item of the Proxy Service.
Now you have completed configuring the End Point and we move on to configuring the InSequence of the Proxy Service. There exist a Log Mediator in the InSequence. But in this example we don't need it. Therefore we set the Sequence Type as None from the Properties View. Then the existing Log Mediator will be removed from it.
Now that you have successfully completed configuring the InSequence, now it is time to configure the OutSequence. First, change the Sequence Type value in the Properties View to Anonymous. Then select the OutSequence and select New Child => Sequence (Anonymous) from the right click menu.
Now select Sequence (Anonymous) and then right click on it and select New Child => Core => Send. This adds a Send Mediator to your OutSequence. This is shown in the image below.
Now you have completed configuring the Proxy Service for the ESB. In the nexet section let's see how we can create a connection to a WSO2 Carbon Based ESB placed in your Local File System.
Adding a WSO2 Carbon Based Server to the Carbon Studio IDE.
When you install the Carbon Studio, a new view called Servers appear in the IDE. All the existing server applications such as Apache Tomcat, WSO2 WSAS, WSO2 ESB, etc can be integrated to the IDE from there so that these server instances can be managed from the IDE itself. In this example we will show integrating WSO2 ESB to the IDE. First open the Servers View and right click on it and select New => Server from it.
Then you will get a new Dialog Box where you can sprcify the Sevrer instance and configure it. In this Dialog Box, select WSO2 => WSO2 Carbon 3.0.1 Serve for Server Type. Then you need to mention the Server Host Name. By default the value is localhost and you need not to change it. In the place where you can specify the Server Name, you can type a name for the server or keep the default name. In the Server Runtime Environment, you have to point to the Server instance where it resides in the local file system. In order to do that click on Add hyperlink next to the text box.
When you click on the Add hyperlink as we mentioned above, you will get a new Dialog Box where you can point to the ESB instance in the file System. From this Dialog Box, you need to configure the Carbon Home which is the Server instance in the local file system.
To configure that click on the Browse button and you will get a file system browser and from there you need to select the Root folder of the ESB instance in the file system.
Select the Root directory of the ESB instance and click on OK button. Then the selected path will be set as the Carbon Home.
Now click on Finish button and finish the integrating the Server instances to the IDE. Then there will be a ESB instance integrateed to the IDE as shown in the image below.
Starting the WSO2 Carbon Based ESB from the Carbon Studio IDE
Now you have integrated the ESB instance to the IDE, we look at how to start the ESB instance from the Carbon Studio IDE. There are 2 methods to do that from the Carbon Studio. If you select the ESB instance in the Servers View, you will notice that there is a Start icon in the top right corner. Else you can right click on the ESB instance and select Start from there.
When you start the ESB from the IDE, there will be service logs shown in the console of the IDE. These log messages are identocal to the messages you get when you invoke the ESB from the platform console.
If you have successfully started the ESB, ESB Web Console will be opened in the Brwoser automatically. Use default credentials for WSO2 prducts (Username=admin and Password=admin) to log in to the ESB Web console.
When you log in to the system, ESB dash board will appear as shown below. This means you have successfully managed to start the ESB from the Carbon Studio IDE.
Deploying the creted Proxy Service in the server instance using Carbon Studio IDE
Now we look at how can we deploy the created Proxy Service using the Carbon Studio IDE. First check what are the existing Services in the ESB from the Web console by selecting List under Services section in the left panel.
The Proxy Service we created was StockQuoteProxy and it is not currently deployed in the ESB as a service. In order to deploy the created service right click on the cretaed CApp project and select Run As => Run on Server. efore trying to deploy the service, you must start the ESB as we described in the above section.
Then a new Dialog Box will appear and it will show what are the currently running WSO2 Carbon based server instances such as WSO2 WSAS, WSO2 ESB, etc. From that list, select WSO2 ESB instance which you have deployed and click Finish.
Now you have asked Carbon Studio IDE to deply your Proxy Service in the WSO2 ESB and it will do it for you. There will be log messages appear in the Carbon Studio Console about the progress of that deployment. By reading those messages you will be able to identify whether your Proxy Service is successfully deployed or not.
If your Proxy Service is successfully deployed in the WSO2 ESB, you can go to the WSO2 ESB web console and check what are the existing service by selecting List under Service section in the left panel. If the deployment is successful, your StockQuoteProxy will appear in this list as shown in the image below.
Follow the procedure starting from Starting the Sample Apache Axis2 Server described in the original sample to run the service and utilize it.