WSO2 developer studio helps you to develop, deploy and test WSO2 ESB artifacts such as Proxy service, Sequences, APIs. After setting up ESB development environment using WSO2 developer Studio properly, it is just few steps to deploy artifact to server and test it while you are developing ESB artifacts.
Prerequisites
WSO2 Enterprise Service Bus - 4.8.0
WSO2 Developer Studio - 3.3.0 Alpha3 (
http://builder1.us1.wso2.org/~developerstudio/developer-studio/3.3.0/Alpha3/installed-distributions/)
Setup Development Environment
1. Download and install both WSO2 ESB & WSO2 Developer Studio. I'll use 'ESB_HOME' to refer ESB installation directory throughout this article.
2. Go to Developer Studio dashboard and click on "Server" link.
3. Select "WSO2 Carbon 4.2 based server" in the wizard page(you can find this under WSO2 category). Give a server name. Click Next.
4. Give 'ESB_HOME' (ESB Installation directory location) for CARBON_HOME. In my case CARBON_HOME is "/media/Manganese/WSO2/Products/wso2esb-4.8.0". Click Next.
5. We can change ports for running ESB in next page. But we are not going to do that this time. So click Finish.
6. Server View will be pop up with the added ESB server. Click the 'Restore' icon in the Right corner of the Server view to set the Server View in a fixed position in Developer Studio workbench. You have added an ESB server to Developer Studio. Now You can do server operation such as Server Start, Shutdown, deploy artifacts etc. through Developer Studio.
7. Lets start the ESB. Right click on added server in the Server view, click on 'Start' in the context menu. ESB will be started. It will take few seconds to complete the startup process. You can monitor the server logs using 'Console' view in Developer Studio.
8. Now we have setup a WSO2 ESB and it is running. Let's start development. I'm going to implement a simple Proxy service which invoke a backend web service after logging the actual request. And this proxy service will send the backend response back to the client. First create an 'ESB Config project' (Ex : MyESBProject). Create a Custom Proxy service inside it (Ex : MyProxyService). You can use Developer Studio dashboard for this.
9. Drag and drop a Log mediator to the InSequence of the Proxy service(Top arrow at the left hand side indicates the beginning of the InSequence). Go to Properties view of the Log mediator and change the Log Level to "full". Then drop a Send mediator after the Log mediator. Drop a Address Endpoint into the Send mediator. I'm going to keep this article simple. So I'm using the "echo" axis2 service deployed in ESB itself, as my backend. So give https://localhost:8243/services/echo as the "uri" of the Address endpoint.
10. Let's design the outSequence of the proxy service. Add a Send mediator to the outSequence (Bottom arrow at the right hand side indicates the beginning of the outSequence).
11. Save the diagram.
12. We have completed the implementation our configuration. All we need is to deploy this configuration to our ESB and test it. We need to create a "Composite Application Project" to deploy this proxy service to ESB. Goto Developer Studio dashboard and click on "Composite Application Project" link. Give a name for project(Ex : MyCapp) and select created proxy service as a Dependency. Then click finish. (Before creating "Composite Application Project", deselect ESBConfig project from the Project Explorer if it has been selected. Otherwise "Composite Application Project" project will be created inside the ESBConfig Project as a child project.)
13. When we create a Proxy Service, Developer Studio changes its perspective to "WSO2 ESB Graphical" from "Java EE" perspective. So Server View will not be there in the workbench now. So goto Window --> Show View --> Other and select Servers from the dialog box and click OK. Server view will be pop up with the created ESB server.
14. We need to add the created "Composite Application Project" to the added ESB server in server view. There are two ways to do this.
(i) Drag and drop the created "Composite Application Project" (Ex : MyCapp) from the project explorer, on to the created ESB server of the Server view.
(ii) Right click on added ESB server (Ex : MyESB) in the sever view and select "Add and Remove..." from the context menu. Then add created "Composite Application Project" (Ex : MyCapp) and untick "If server started, publish changes immediately" checkbox. Click finish.
15. Lets deploy "MyCapp" to the server. Since we have included the proxy service inside this "MyCapp", this operation ultimately will deploy the proxy service to the ESB. So right click on "MyCapp" in server view and click on "Redeploy" from the context menu.
16. "MyCapp" will be deployed to the ESB and then deploys the proxy service.
17. We can test this proxy service using SoapUI plugin in Developer Studio. Goto Window --> Open Perspective --> Other. Select SoapUI perspective and click OK.
18. Now we are in the SoapUI perspective. Create a new SoapUI project by giving wsdl of the deployed proxy service. We can find it from WSO2 ESB management console. (In my case it is http://localhost:8280/services/MyProxyService?wsdl).
19. Then send the following request to the proxy service from SoapUI.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">
<soapenv:Header/>
<soapenv:Body>
<echo:echoString>
<!--Optional:-->
<in>foo</in>
</echo:echoString>
</soapenv:Body>
</soapenv:Envelope>
you will get the following response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:echoStringResponse xmlns:ns="http://echo.services.core.carbon.wso2.org">
<return>foo</return>
</ns:echoStringResponse>
</soapenv:Body>
</soapenv:Envelope>
20. Change the perspective to "WSO2 ESB Graphical" and get the "Console view" You can see the request has been logged in the console as well. (this is because we have put a Log mediator in the inSequence of the proxy service)
[2013-12-15 06:50:49,452] INFO - LogMediator To: /services/MyProxyService.MyProxyServiceHttpSoap11Endpoint, WSAction: urn:mediate, SOAPAction: urn:mediate, MessageID: urn:uuid:20a4f818-b31b-4600-914d-a703c2a9169a, Direction: request, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Body>
<echo:echoString>
<!--Optional:-->
<in>foo</in>
</echo:echoString>
</soapenv:Body></soapenv:Envelope>
21. Now you know how to develop, deploy and test a proxy service using WSO2 Developer Studio. You can continue your development of the proxy service through WSO2 Developer Studio, when you want to test your proxy service while development, all we need is to save the diagram and redeploy the "MyCapp" using steps mentioned in step 15 and test it.
22. For example lets add another log mediator to the outSequence and set the "Log Level" to "full" to log the response.
23. Save the diagram. Right click on "MyCapp" in server view and click on "Redeploy" from the context menu. It will take few seconds to deploy the proxy service.
24. Invoke the proxy service using SoapUI using the same request. You can see the response massage has been logged in the Console.
2013-12-15 06:50:49,469] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:0c70044b-e510-409f-9a2e-e5f628da9f2e, Direction: response, Envelope: <?xml version="1.0" encoding="utf-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:echoStringResponse xmlns:ns="http://echo.services.core.carbon.wso2.org"><return>foo</return></ns:echoStringResponse></soapenv:Body></soapenv:Envelope>