Sunday, September 4, 2016

How to set a static response or property in class mediator in WSO2 ESB

WSO2 ESB provides us luxury to create a custom functionality in java as class mediator. In class mediator we can write our desired functionality in java class and that can be called from the ESB synapse file. We can pass some property from ESB file to class mediator and in a same way we can set some property in java class and that can be read from synapse file.

Here is an example in which I need to reply a static response to customer. However this can be done from many ways but I am choosing class mediator just to show how this can be done from class mediator.


 I want below static response to be shown in as actual response of the service. I have put this “StaticEmployeeDetails.xml” file in “XX\wso2esb-4.0.3\repository\conf\stub\StubXml\ StaticEmployeeDetails.xml” location.

Static XML Code:

<EmployeeDetails xmlns="http://shriwithjava.blogspot.co.nz/">
   <EmployeeData>
      <EmployeeId>201</EmployeeId>
      <EmployeeName>Shri</EmployeeName>
      <EmployeeAddress>Auckland</EmployeeAddress>
      <Department>IT</Department>
   </EmployeeData>
   <EmployeeData>
      <EmployeeId>202</EmployeeId>
      <EmployeeName>Bhajan</EmployeeName>
      <EmployeeAddress>Wellington</EmployeeAddress>
      <Department>IT</Department>
   </EmployeeData>
</EmployeeDetails>



Here is the Class mediator code which will be called from the wso2 Synapse file.

Class Mediator Code:

package org.wso2.custom;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.apache.synapse.MessageContext;
import org.apache.synapse.mediators.AbstractMediator;

public class CustomMediator extends AbstractMediator {

                private static String Response = "StaticResponse";
                private static String ResponseXml = "";
                private static String FileName = "";
                private static String FilePath = "F:\\Shri Kant\\WSO2\\wso2esb-4.0.3\\repository\\conf\\stub\\StubXml\\";
                public boolean mediate(MessageContext context) {
                                // TODO Implement your mediation logic here
                                //FileName=context.getProperty("").toString();
                                FileName=(String)context.getProperty("FileName");
                                BufferedReader br = null;
                                try {

                                                String sCurrentLine;

                                                br = new BufferedReader(new FileReader(FilePath+FileName+".xml"));

                                                while ((sCurrentLine = br.readLine()) != null) {
                                                                ResponseXml+=               sCurrentLine;
                                                }
                                                context.setProperty(Response, ResponseXml);
                                               
                                                System.out.println(context.getSoapAction()+" : This is the SOAP Action");
                                                System.out.println(context.getConfiguration()+" : This is the getConfiguration");
                                                System.out.println(context.getMessageID()+" : This is the getMessageID");
                                                System.out.println(context.getTracingState()+" : This is the getTracingState");
                                                System.out.println(context.getWSAAction()+" : This is the getWSAAction");
                                                System.out.println(context.getWSAMessageID()+" : This is the getWSAMessageID");
                                                System.out.println(context.getClass()+" : This is the getClass");
                                                System.out.println(context.getContextEntries()+" : This is the getContextEntries");
                                                System.out.println(context.getEnvelope()+" : This is the getEnvelope");
                                                System.out.println(context.getEnvironment()+" : This is the getEnvironment");
                                                System.out.println(context.getFaultSequence()+" : This is the getFaultSequence");
                                                System.out.println(context.getFaultStack()+" : This is the getFaultStack");
                                                System.out.println(context.getPropertyKeySet()+" : This is the getPropertyKeySet");
                                                System.out.println(context.getServiceLog()+" : This is the getServiceLog");
                                                System.out.println(context.isDoingGET()+" : This is the isDoingGET");
                                                System.out.println(context.isDoingMTOM()+" : This is the isDoingMTOM");
                                                System.out.println(context.isDoingPOX()+" : This is the isDoingPOX");
                                                System.out.println(context.isDoingSWA()+" : This is the isDoingSWA");
                                                System.out.println(context.isFaultResponse()+" : This is the isFaultResponse");
                                                System.out.println(context.isSOAP11()+" : This is the isSOAP11");
                                                System.out.println(context.isResponse()+" : This is the isResponse");
                                               
                                } catch (IOException e) {
                                                e.printStackTrace();
                                } finally {
                                                Response="";
                                                try {
                                                                if (br != null){
                                                                                br.close();
                                                                               
                                                                }
                                                } catch (IOException ex) {
                                                                ex.printStackTrace();
                                                }
                                }
                               
                               
                                return true;
                }
}




  • ·         Different property has been used in above code just to show that what all we can set from class mediator and use it in our synapse file.
  • ·         Create ja jar file of this above code and place it in the “X\ wso2esb-4.0.3\repository\components\lib\CustomMediator.jar”
  • ·         Now we need to provide the reference of this class from the synapse.xml file

I am creating a service “MyCustomProxy”. You can see that I have used “<class name="org.wso2.custom.CustomMediator"/>” code to call the class mediator. I have also used the javascript function which will change the response from string to xml. “<property name="StaticResponse" action="set" expression="get-property('StaticResponse')"/>” is used to get response from the class mediator which will be read from the static xml file.

Synpse.xml:

<localEntry key="StaticServiceScript" src="file:repository/conf/stub/StaticTransformResponse.js"/>
               
<proxy name="MyCustomProxy" transports="http" startOnLoad="true" statistics="enable" trace="disable">
                <target inSequence="MyCustom_IN" outSequence="MyCustom_OUT" faultSequence="CommonFaultHandler"/>
                <publishWSDL key="MyCustom_wsdl"/>
</proxy>
<localEntry key="MyCustom_wsdl" src="file:repository/conf/employee/OverseaseEmployee.wsdl"/>
<sequence name="MyCustom_IN">
                <property name="FileName" value="StaticEmployeeDetails" action="set"/>     
                <class name="org.wso2.custom.CustomMediator"/>
                <property name="StaticResponse" action="set" expression="get-property('StaticResponse')"/>
                <script language="js" key="StaticServiceScript" function="sendStaticResponse"/>
                <property name="RESPONSE" value="true"/>
                <header name="To" action="remove"/>
                <send/>
                <drop/>
</sequence>    




Java Script Code:
I am using a java script code which will be called from synapse.xml file. This will create a string text to xml content.

StaticTransformResponse.js


<x><![CDATA[  

                function sendStaticResponse(mc) {
                var StaticResponse = new XML(mc.getProperty("StaticResponse"));
                                                mc.setPayloadXML(StaticResponse);
               
                  }
]]></x>




Just restart the server to reflect the changes and hit the “MyCustomProxy” service and you will get the desired response. If you want to change the static response just change the content of the “StaticEmployeeDetails.xml” file located inside of “wso2esb-4.0.3\repository\conf\stub\StubXml” and restart the server.


Above image shows all the parameter what we have set in out java class. Same things we can get it in synapse.xml file as per our requirement.

Monday, August 1, 2016

How to use Clone Mediator in WSO2 ESB

Clone mediator is used to send same massage to multiple endpoints. It basically clone same message to multiple message based on our requirement and send it to multiple endpoints. We can aggregate the response which we get from the multiple endpoints and show as one response.

Requirement:

Suppose there is a requirement where we have to get the entire IT employee details who all works overseas. We have different databases and different places and each database has employee records. We have only one input parameter which is department, all I need is IT employee details.

Solution:

I have created 3 data services, first provides Indian employee detail, second provide USA employee details and 3rd provides New Zealand employee details. I have created same format DSS with same namespace with one input parameter and 4 output parameter in one employee list and response can have multiple employee list.


DSS:
<data name="EmployeeDetailsNZ" enableBatchRequests="false" enableBoxcarring="false" serviceStatus="active">
   <description>This provides Employee details</description>
   <config id="EMPDS">
      <property name="org.wso2.ws.dataservice.driver">oracle.jdbc.driver.OracleDriver</property>
      <property name="org.wso2.ws.dataservice.protocol">jdbc:oracle:thin:SYSTEM/SYSTEM@localhost:1521/xe</property>
      <property name="org.wso2.ws.dataservice.user">SYSTEM</property>
      <property name="org.wso2.ws.dataservice.password">SYSTEM</property>
      <property name="org.wso2.ws.dataservice.minpoolsize"></property>
      <property name="org.wso2.ws.dataservice.maxpoolsize"></property>
      <property name="org.wso2.ws.dataservice.validation_query"></property>
   </config>
   <query id="EmpDetailsQuery" useConfig="EMPDS">
      <sql>select * from EMP_DETAILS_NZ where DEPARTMENT_V=?</sql>
      <result element="EmployeeDetails" rowName="EmployeeData" defaultNamespace="http://shriwithjava.blogspot.co.nz/">
         <element name="EmployeeId" column="EMP_ID_N" xsdType="xs:string" />
   <element name="EmployeeName" column="EMP_NAME_V" xsdType="xs:string" />
   <element name="EmployeeAddress" column="EMP_ADD_V" xsdType="xs:string" />
   <element name="Department" column="DEPARTMENT_V" xsdType="xs:string" />
   </result>
      <param name="Department" paramType="SCALAR" sqlType="STRING" type="IN" />
   
   </query>
   <operation name="getEmployeeDetails">
      <description></description>
      <call-query href="EmpDetailsQuery">
         <with-param name="Department" query-param="Department" />
   
      </call-query>
   </operation>
</data>

DSS request and response format:

Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:shr="http://shriwithjava.blogspot.co.nz/">
   <soapenv:Header/>
   <soapenv:Body>
      <shr:getEmployeeDetails>
         <shr:Department>IT</shr:Department>
      </shr:getEmployeeDetails>
   </soapenv:Body>
</soapenv:Envelope>

Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <EmployeeDetails xmlns="http://shriwithjava.blogspot.co.nz/">
         <EmployeeData>
            <EmployeeId>201</EmployeeId>
            <EmployeeName>Shri</EmployeeName>
            <EmployeeAddress>Auckland</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
         <EmployeeData>
            <EmployeeId>202</EmployeeId>
            <EmployeeName>Bhajan</EmployeeName>
            <EmployeeAddress>Wellington</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
      </EmployeeDetails>
   </soapenv:Body>
</soapenv:Envelope>



ESB Changes:

I have created a service which will get all the details of the overseas employee for different department. I will call all the endpoints (Indian, USA and New Zealand employee details) and aggregate the response into one. I have to use same input and that will be cloned for each endpoint from the clone mediator.

Synapse Code:

<definitions>
<proxy name="OverseasEmpDetailsProxy" transports="http" startOnLoad="true" trace="disable" statistics="enable">
   <target inSequence="OverseasEmpDetails_IN" outSequence="OverseasEmpDetails_OUT" faultSequence="CommonFaultHandler"/>
   <publishWSDL key="OverseasEmpDetails_wsdl"/>
</proxy>
<localEntry key="OverseasEmpDetails_wsdl" src="file:repository/conf/employee/OverseaseEmployee.wsdl"/>
 
<sequence name="OverseasEmpDetails_IN">
 <clone>
  <target>
   <endpoint key="NZEmployeeDetails_EPR"/>
  </target>
  <target>
   <endpoint key="INDEmployeeDetails_EPR"/>
  </target>
  <target>
   <endpoint key="USAEmployeeDetails_EPR"/>
  </target>
 </clone>
</sequence>
 
<sequence name="OverseasEmpDetails_OUT">
   <aggregate>
  <completeCondition>
   <messageCount min="-1" max="-1"/>
  </completeCondition>
  <onComplete xmlns:shr="http://shriwithjava.blogspot.co.nz/" expression="//shr:EmployeeDetails/shr:EmployeeData">
   <send/>
  </onComplete>
 </aggregate>
</sequence>
 
 <endpoint name="NZEmployeeDetails_EPR">
 <address uri="http://localhost:9763/services/EmployeeDetailsNZ">
  <timeout>
   <duration>10000</duration>
   <responseAction>fault</responseAction>
  </timeout>
  <suspendOnFailure>
   <errorCodes>101500,101501,101506,101507,101508</errorCodes>
   <progressionFactor>0.0</progressionFactor>
  </suspendOnFailure>
  <markForSuspension>
   <errorCodes>101504,101505</errorCodes>
  </markForSuspension>
 </address>
</endpoint>
 <endpoint name="INDEmployeeDetails_EPR">
 <address uri="http://localhost:9763/services/EmployeeDetailsIndia">
  <timeout>
   <duration>10000</duration>
   <responseAction>fault</responseAction>
  </timeout>
  <suspendOnFailure>
   <errorCodes>101500,101501,101506,101507,101508</errorCodes>
   <progressionFactor>0.0</progressionFactor>
  </suspendOnFailure>
  <markForSuspension>
   <errorCodes>101504,101505</errorCodes>
  </markForSuspension>
 </address>
</endpoint>
 <endpoint name="USAEmployeeDetails_EPR">
 <address uri="http://localhost:9763/services/EmployeeDetailsUSA">
  <timeout>
   <duration>10000</duration>
   <responseAction>fault</responseAction>
  </timeout>
  <suspendOnFailure>
   <errorCodes>101500,101501,101506,101507,101508</errorCodes>
   <progressionFactor>0.0</progressionFactor>
  </suspendOnFailure>
  <markForSuspension>
   <errorCodes>101504,101505</errorCodes>
  </markForSuspension>
 </address>
</endpoint>
 
<sequence name="CommonFaultHandler">
 <log level="custom">
  <property name="MESSAGE" value="Executing default &quot;fault&quot; sequence"/>
  <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
  <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
 </log>
 <header name="To" action="remove"/>
 <drop/>
</sequence>
 
 
</definitions>


Restart the ESB and load the WSDL in SOAP UI results will look like:

Request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:shr="http://shriwithjava.blogspot.co.nz/">
   <soapenv:Header/>
   <soapenv:Body>
      <shr:getEmployeeDetails>
         <shr:Department>IT</shr:Department>
      </shr:getEmployeeDetails>
   </soapenv:Body>
</soapenv:Envelope>


Response:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Body>
      <EmployeeDetails xmlns="http://shriwithjava.blogspot.co.nz/">
         <EmployeeData>
            <EmployeeId>201</EmployeeId>
            <EmployeeName>Shri</EmployeeName>
            <EmployeeAddress>Auckland</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
         <EmployeeData>
            <EmployeeId>202</EmployeeId>
            <EmployeeName>Bhajan</EmployeeName>
            <EmployeeAddress>Wellington</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
         <EmployeeData>
            <EmployeeId>004</EmployeeId>
            <EmployeeName>Viru</EmployeeName>
            <EmployeeAddress>Kanpur</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
         <EmployeeData>
            <EmployeeId>111</EmployeeId>
            <EmployeeName>Tahseen</EmployeeName>
            <EmployeeAddress>New York</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
         <EmployeeData>
            <EmployeeId>113</EmployeeId>
            <EmployeeName>JD</EmployeeName>
            <EmployeeAddress>Washington</EmployeeAddress>
            <Department>IT</Department>
         </EmployeeData>
      </EmployeeDetails>
   </soapenv:Body>
</soapenv:Envelope>

You can see the response from different service have been merged into one and we only sent a single request with a department parameter.

Thursday, February 18, 2016

How to Create BPEL process in WSO2 BPS (Service Orchestration)

WSO2 BPS uses Business process execution language to do orchestration. We can use some internal, external service or xpath calculation inside the BPS process. In this tutorial, we are going to solve a formula (X^2+Y^2)^2. To solve this formula we need two services, 1st which gives the square result of a value and 2nd provides the adding functionality. Both square and adder service have been created in ESB. We will use this ESB WSDL in this BPS process.

So first we need to create 2 services which provide square and adding functionality.

ESB Services:

  • I have created GetSquareService in ESB which takes input as X and provides its square result as mentioned below.


  • There is another service I have created which returns addition of two numbers.

By these two above service, I will be able to solve the formula in BPS because formula uses only square and addition functionality.

BPS Service Creation:

To start with BPS process, we need to have eclipse which has the plugins to create BPEL flow. If you don’t have it, please download from WSO2 website.

Once you have pre-requisite things you can start with below steps.

  • Go to file menu, select new then other, below window will pop up and choose the BPEL project.
  • Give a project name, you are going to create. I have given FormulaCalculator for this blog as below. Click on finish.
  • Now create a BPEL process file in which we will define our process flow and complete logic. To do that chose the “New BPEL Process File” as below and click on Next button.
  • Click Next button to give BPEL file name, namespace and template type, in this tutorial I have given  BPEL name as FormulaCalculator, namespace as shriwithjava.blogspot.co.nz and chosen synchronous type template as mentioned below.
  • Click Next button, below screen will pop up with some information. If you want to make any changes then make it, otherwise click on finish.
  • If you click on the Next button then below screen will come otherwise click on Finish button.
  • Once you click on finish button, your file will look like below screenshot in which you can write your logic.

If you see at left hand side files, there are to files have been created. One is BPEL file which we have created and other one is WSDL file (FormulaCalculatorArtifacts.wsdl). This WSDL actually decides that what kind of parameter this BPS process is going to take and which kind of output, this process provides. 

  • So as we have decided that we are going to solve (X^2+Y^2)^2 formula so according to this input should be 2 as part of X and Y. In below screenshot we are making changes in WSDL file according to our requirement.
  • I have made changes in request field and this takes input as X and Y as mentioned below screenshot.
  • Same we have make changes in output as response as mentioned below. In this process our output will be one, which I have taken it as FormulaResult.
  • Now copy ESB WSDL in this project which we have created in ESB one is for Adder Service and other one is for the square service. It should be as below screen.
  • BPS process provides functionality to create partner link in BPEL in order to use services in our logic. If we have to use GetSquareService and AddNumberService, we have to create two Partner link, one for each. To create a partner link, you have to follow below screen. Click on the + icon given in right side and provide the necessary information. Partner link is same as library file in java, we import library file to use their functionality. Same partner link invokes service to be used inside the BPEL logic.
If you see in above screenshot, I have created 2 Partner Links one is GetSquarePartnerLink and other is AddNumberPartnerLink

  • Once you define a Partner Link, we have to link it with a defined WSDL. To do that, select the Created Partner Link and go to property. In below screenshot, I have selected AddNumberPartnerLink and this need to be linked with WSDL.
  • Click on Property, you will see below screen.
  • Click on the browse button, below screen will popup. Select the AddNumberServicePortType where you will be able to see Partner Link Type Structure.
  • Click on the Add WSDL button, below screen will pop up.
  • Select the WSDL “AddNumberService.wsdl” and click on the ‘OK’ button. Below Screen pop ups in which you have to define Partner Link Type Name.
  • Provide the Partner Link Type name and click Next button. Below screen will be shown in which you have to provide Role Name and select the Port Type. Here we have given Role Name as AddNumberRole and select AddNumberServicePortType. Then click on Finish button.
  • Below screen should be shown in which you can see partner Role and Partner Operation.
  • Repeat the above steps to create another Partner Link for the other service (GetSquareService).
Once you are done with the Partner Link then create variables to be used in the BPEL logic.
  • Click on the below highlighted area in Yellow, give the variable name. In this screenshot I have given variable name for GetSquare request and GetSquare response with the name of “GetSquarePartnerLinkRequest” and “GetSquarePartnerLinkResponse” now select GetSquarePartnerLinkRequest and go to the property.
  • Below Screen will popup, in which you can select GetSquareRequest variable and click OK button as mentioned in below screenshot.
  • You can see in below screenshot that it takes only one parameter as X.
  • In same way as above link GetSquarePartnerLinkResponse with GetSquareResponse.
  • There are some local variable required which holds temporary results like for square, addition etc. these variable can be defined as below. It’s same as we define for other variable. Click on + button in variable lane and give the variable name as Value_Y.
  • Choose this variable as string type, you can select this as any data type like integer, Boolean etc. but in this case I have taken it as String.
  • Once you select this, can see in property that variable is now showing as String datatype
  • In same way as mentioned above, you have to create Value_X, Value_Y and AddedResult variable of String datatype.
  • Now we are all set to proceed with BPEL flow, to start with flow activity you need to use Palette’, where you can see there are lots of activity icons. If it is not open there in eclipse, go to ‘Window’ menu then open ‘Show View’ then select other. In pop up window just type ‘Palette’, below screen will be shown.
  • Now we need to create our logic flow by using this Palette. Click on the “receiveInput” in default BPEL flow and go to the property. You will see below screen just check that “Partner Link” should be ‘client’, Operation should be “FormulaCalculator” and variable should be “input”. This represents that we will receive input from here and executes operation “FormulaCalculator”.
  • Same as above we have to choose output by selecting the “replyOutput”.
  • Screen should look like as below.
  • In this flow now we are trying to invoke a service as mentioned below. To invoke a service we need to use invoke activity from the palette. Choose the invoke activity and provide a desired name, for this tutorial we have given “InvokeGetSquareService”.
  • After clicking the invoke property, we need to link it with service operation and its request & Response. If you see below screenshot, I have selected Invoke property. Partner link showing as GetSquarePartnerLink, operation is showing as GetSquare, request and response showing as GetSquarePartnerLinkRequest and GetSquarePartnerLinkResponse respectively. 
  • In a same way we have to use invoke activity for other service. Before calling any service we have to pass some parameter if service requires any parameter to be passed. This can be done from the “Assign Activity” so for every invoke service I have used Assign Activity before invoke activity. In order to calculate formula we have to invoke 4 times service and 5 times assign service. Flow should be as mentioned below. Wherever I have given name as Invoke Square service, I am using GetSquare Service and wherever I am using name as Invoke Add service, I am calling add service. And in same way we have to choose its request, response, operation and parameter.
  • After creating above flow, now time to assign parameter to the service and whatever response we get it from service as response, we can use it as parameter for other service. To assign first parameter to the service, select “AssignGetSquareInput” assign activity and open property tab.
  • Click on highlighted “New” button  and choose variable to variable (From: variable and to: variable)
  • Select “InputValue_X” from left part (From left section) and link it to the X variable in right part (Right Section). A pop up will appear asking that “variable does not have initializer, should it be generated”, click on “Yes” button. This is done when we are calling a service first time, otherwise it is not required. This is same as we initialize variable in java and in other programming language. Below screen comes.
  • Now default value is pointing to the parameter of GetSquare operation.
  • Now click on next Assign Activity (just after invoke activity) and choose GetSquareResponse to the Value_Y.  Because we know that after invoke service we should get a proper result and this result needs to be stored somewhere so using Value_Y for this.
  • In above screenshot, again we need to get square of second parameter so in a same way we have invoke Square service and pass the parameter  (InputValue_Y) to the service.
  • Now in below screenshot we are trying to get square response of “InputValue_Y” and storing it into another variable (Value_X).
  • In this stage we have got X^2 and Y^2 result which is stored in Value_X and Value_Y variable like X^2=Value_Y and Y^2=Value_X. now we need to add these value, to do that I am passing this value to AddNumberService as mentioned below. I am passing Value_X to X parameter of Add Service, to do that click on below highlighted activity flow.
  • Once you click on assign activity, open property window and assign variables.
  • Once you pass this variable to AddNumberService parameter, it will ask you to initialize this service variable because as of now it is not initialized. Click “Yes” to get this initialized.
  • Now pass other parameter Value_Y to Y in AddNumberService as mentioned below.
  • Now stored the response of AddNumberService into an “AddedResult” variable. To do that click below highlighted assign activity and go to property window.
  • In below screen I am setting AddResult to AddedResult variable.
  • In this position we have reached to X^2+Y^2 and result of this value is stored in “AddedResult” variable and now just need to get square of this variable. In a same way as above pass the AddedResult to value X (Right side) and get the square of it by invoking the Square Service.
  • Just after invoking Square Service store the response in Formula Result. This will be the final result we want to get. To do that just select Square Result and assign it to “FormulaResult” as defined in below screenshot.
  • Our flow is done and this service is now needed to be deployed. If you want to see the code written behind this flow just click on source tab and see the code.

  • This service needs a deployment descriptor file for the deployment in which we define the endpoints references and other details. For adding deployment descriptor file: Go to the File-->New -->others and chose “Apache ODE Deployment Descriptor” as mentioned below.


  • Click Next.
  • Click Finish. File looks as below screenshot.
  • In Inbound Interfaces (Services), open dropdown by clicking Associated Port and select FormulaCalculatorPort as mentioned below.
  • In Outbound Interfaces which we need to invoke (in our case AddNumberService and GetSquareService) so select the reference Endpoints of these services.
  • For deploying this BPS process, we have to make .zip file and upload it from the console UI. So copy all the required file and make a zip of that.
  • Start the BPS server and login to console UI.
  • Click on the highlighted “Add BPEL” link above page will be open. Click on browse button and select the .zip file and click on upload.
  • If everything goes successful then above screen will popup saying “BPEL package uploaded successfully”.
  • If you now check the List of services then FormulaCalculator will be shown as above screenshot. Now to test this service just click on the “Try this Service” below screen will come and test it with desired parameter.
  • In above screenshot I have passed values 3 and 4 and result is coming right as 625
(X^2+Y^2)^2 = (3^2+4^2)^2 = 625
  • This is what we wanted to achieve.