Powered By Blogger

Jan 22, 2014


Modelling a BPEL Process


This blog post describes how to model a BPEL process via WSO2 Developer Studio.

As prerequisites you need to download [1], [2]

[1] WSO2 Developer Studio http://wso2.com/products/developer-studio/
[2] WSO2 BPS 3.1.0 - http://wso2.com/products/business-process-server/


This shows a simple process to add two integers.

  • Go to the Developer Studio dashboard and then click on Composite Application Project. Then give a project name. 




  • Then right click on the created CApp go to New -> BPEL Workflow
  • Then from the wizard select option 'Create new BPEL Workflow' and click on Next.
  • Give a name for the project, process and since this is a synchronous business process select 'Synchronous BPEL Process' as the template and click on Finish

  • If you go to the project explorer you can see a process called Adding.bpel has been created and it will displays as follows.

    • Now open the AddingArtifacts.wsdl file and go to the design view. Then click on the arrow next to Adding Request.
  • Then a new tab will be opened named Inline Schema for AddingArtifacts.wsdl. Under the AddingRequest Type insert a variable called 'a' with the type int. Then right click on the AddingRequest Type and click on Add Element. Then add another variable called 'b' with the type int. Finally it will looks like below.
  • Now we can design the simple business logic. Open the Adding.bpel file and then in order to add the business logic you need to select and delete the 'FIX_ME-Add_Business_Logic_Here' element. 
  • Then you need to add a Assign activity in between receiveInput and replyOutput, you can drag and drop from the Action pallet or right click Add-> Assign.
  • Now click on the Assign and go to the properties window and select 'Details' tab then click on 'New'. Then select 'Expression' from the 'From' drop down and 'Variable' from the 'To' drop down.  Then in the 'Edit the associated XPath Expression' type "$input.payload/tns:a + $input.payload/tns:b" and then select  "result:string" under 'To' as the assigned variable.




  • Then a pop up will ask to initialize the variables click on 'Yes'
  • Now you need to define inbound and out bound interfaces. Go to the deploy.xml file which is in the BPEL project. Then select AddingPort as the inbound address port from the given list. Rest of the parameters will be automatically filled once you select it.

  • Now go the pom.xml of the CApp and include the bpel process as the dependency. Select Business Process Server as the server role.
  • Now you can right click on the CApp and export it as a a composite application project. 
  • Finally you can start the BPS server and then deploy the .car

Jan 14, 2014


Applying QoS

Applying Quality of Service to Web Services is vital since it creates high quality of services in terms of non functional attributes like security and reliability. QoS can be applied to Web Services by associating it with the Web Service Definition Language (WSDL).


Below example shows how to apply QoS (Quality of Service) for a service via Developer Studio and deploying it in the server.


  • First deploy the service to the server and get the URI of the WSDL.
  • Then right click on the project where you want to apply QoS and then select “Apply QoS” from the menu. Then you will get a wizard to create a new QoS project. Give a name for the project and select Next.

    • After that you can give the URI of the WSDL as shown below in the WSDL Selector wizard under the ‘WSDL URI’ option.  Then click on Next.

      Note :

      1. If you are using an Axis2Service Project, after creating the project you can right click on the project and select ‘Generate WSDL’. Then in the WSDL Selector wizard,  under the ‘Browse workspace’ option you can browse to the relevant wsdl file as shown below.
      2. If your Axis2Service Project has existing WSDL, then you can choose ‘Browse file system’ option under the  WSDL Selector wizard.


      • After that you can give relevant maven information for the project and finally click on Finish.
      • Now you can see the QoS project has been created in the Project Explorer.
      • In the QoS editor you can go the “Service Info” category and enable security by selecting ‘Yes’ from the combo box.


      • After selecting the relevant options you can click on ‘Save’
      Note:

      1. Basic Scenarios

      If you select ‘Username Token’ under the ‘Security for the service’ category and ‘Basic scenarios’ sub category then you have to click on ‘User Roles’ button.

      Then a window will pop up as shown below. Please make sure your server is running at this time. Then fill the relevant information.

      After that under the ‘Roles’ section of the above window click on ‘Get Roles’ button. Then you will get a chance to select the roles as shown below.

      Then click on ‘OK’.

      2.  Policy from Registry

      If you select the option ‘registry’ under the ‘Security for the service’ category and ‘Policy from Registry’ sub category then click on ‘Browse from Registry’ button.





      Then a window will pop up and then click on the ‘registry’ link



      Then another window will pop up to select the policy file. Select the policy file and click on ‘OK’


      • If you go through the created QoS project you can see a policy file has been created inside the project. You can view it by right clicking on it and open it with xml editor.




        • Next create a CApp including the QoS project you created and then create a CAR.
        • If you haven’t deploy the CApp created including the project which you applied QoS then first deploy it in the server.
        • After that you can deploy the CAR which created including the QoS in the server.




Deploying a Carbon Application


This blog post describe how to deploy the Carbon Application (CApp) to the server via wso2 Developer Studio

As prerequisites you should download [1] & [2]

[2] WSO2 Developer Studio - http://wso2.com/products/developer-studio/

1. Creating the CApp

Let's assume you want to deploy a proxy service in the ESB server. In that case 1st you need to create an ESB project (ESBProject)  containing the proxy (proxy_1)

Then go to the Developer Studio dashboard and select on 'Composite Application Project' then you will get a wizard. In that wizard give a name for the CApp and the under dependencies select the projects you want to include in the CApp and click 'Finish'



2. Package as a CAR (Carbon Application Achieve)

This can be done in two ways

(a) Package as CAR using Developer Studio
(b) Package as CAR using maven


Package as CAR using Developer Studio

You can right click on the created CApp and select 'Export as Composite Application Project' from the menu. Then you can specify a name and a destination from the wizard.


Now a .car file as been created at the given destination

Package as CAR using maven

You can go the location of the ESB project and then build it using 'mvn clean install'



Then go the location of the created CApp and build it using 'mvn clean install'. After building if you go inside the CApp and see a folder called 'target' has been created (initially only the pom.xml file was there) . Inside the target folder you can see the .car file has been created.



3. Deploy the CAR

Now you can go the management console of ESB and then Carbon Applications-> Add and browse to the .car file



Once you click on the Upload button you will get a notification as below if it get uploaded successfully



If you  navigate to the Services category in the management console and list the services you can see the proxy service which you have deployed is there.






Jan 5, 2014

JMS messaging with ESB and MB


This post describes how to integrate WSO2 ESB(Enterprise Service Bus) with WSO2 MB (Message Broker) to facilitate message brokering.

As prerequisites you need to download [1] & [2].


Please note that WSO2 uses same port (0) as the default port in all products' configuration, since we cannot start multiple products with the same port in the same environment we need to change either ports in order to avoid port conflicts. In this example I have changed the port of MB to 1.

Configure MB:

1. Change the offset.

 Go to <Product Home>/repository/conf/carbon.xml and change the offset to 1

<Ports> <!-- Ports offset. This entry will set the value of the ports defined below to the define value + Offset. e.g. Offset=2 and HTTPS port=9443 will set the effective HTTPS port to 9445 --> <Offset>1</Offset>

2. Start MB

Run <MB_HOME>/bin/wso2server.sh (on Linux) or  <MB_HOME>/bin/wso2server.bat (on Windows) 


Configure ESB:


1. Enable the JMS transport


This is needed to communicate with the MB. You can do this by uncommenting transport receiver and transport sender.


Go to <ESB_HOME>/repository/conf/axis2/axis2.xml file and find the commented <transport receiver> and uncomment it. Then find the <transport sender> and uncomment it as well.

2. Copy relevant client libraries of MB to ESB


Go to <MB_HOME>/clent-lib folder and copy the below mentioned libraries and paste it to <ESB_HOME>/repository/components/lib folder.


  • andes-client-0.13.wso2v8
  • geronimo-jms_1.1_spec-1.1.0.wso2v1

Go to the  <ESB_HOME>/repository/conf/ JNDI.proerties file and define a queue. I have defined a queue called  TestStockQuotesQueue. In order to avoid getting 'javax.naming.NameNotFoundException: TopicConnectionFactory’  during server startup, point 'TopicConnectionFactory' also to the Message Broker



3. Point to the running MB

# register some connection factories # connectionfactory.[jndiname] = [ConnectionURL] connectionfactory.QueueConnectionFactory = amqp://admin:admin@clientID/carbon? brokerlist='tcp://localhost:5673' connectionfactory.TopicConnectionFactory = amqp://admin:admin@clientID/carbon? brokerlist='tcp://localhost:5673' # register some queues in JNDI using the form # queue.[jndiName] = [physicalName] queue.TestStockQuotesQueue = TestStockQuotesQueue



4. Start ESB

Run <ESB_HOME>/bin/wso2server.sh (on Linux) or <ESB_HOME>/bin/wso2server.bat (on Windows).


For testing purposes I have used the SimpleStockQuoteService. 

  • Go to <ESB_HOME>/samples/axis2Server/src/SimpleStockQuoteService and run ‘ant’ to build the sample and deploy background services.
You can create two proxy services in ESB as follows

1. Here I am going to create the consumer first. Create a JMS proxy by the name “TestStockQuotesQueue”. Please note this name should be as same as the name defined in the jndi.properties file. In here the message which is consumed from the JMS queue is sent to the relevant endpoint.




Setting up the backend:

The out only scenario

In this scenario is I am going to store a message received to a http proxy of the ESB in a JMS queue. Then consume that queue and get the message and finally send it to the actual endpoint.

<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestStockQuotesQueue" 
transports="jms" statistics="disable" trace="disable" startOnLoad="true">
  <target>
     <inSequence>
        <log level="full"/>
        <property name="OUT_ONLY" value="true"/>
        <send>
           <endpoint>
           <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
           </endpoint>
        </send>
     </inSequence>
  </target>
  <description></description>
</proxy>


2. Then I am going to create HTTP proxy to be used to send the message to JMS queue.


<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestStockQuoteProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence> <property name="OUT_ONLY" value="true"/> <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/> <send> <endpoint> <address uri="jms:/TestStockQuotesQueue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=queue"/> </endpoint> </send> </inSequence> </target> <description></description> </proxy>

Now when the 'TestStockQuoteProxy' is invoked, it will send the message to the queue. Then the message will be consumed by the JMS proxy 'TestStockQuotesQueue' and send to the actual endpoint.
Execute the scenario

You can use SOAP UI to send a request to 'TestStockQuoteProxy' and can see the message has been logged in ESB console and the output will be in the axis2server.