Saturday, 22 October 2016

Operation Based Routing using mediator

 Operation based routing from Mediator 



Mediator is one very important component of SOA Suite.  Mediator is routing mechanism, decide which BPEL or service need to be called. There can be five different type of routing, which is possible is using the mediator.

1. Operation Based Routing

2. Content based routing.

3. Dynamic Routing

4. Event based Routing.

5. Header Based routing.


In the current example we are talking about the operation based routing. Other examples which will be followed in the other following posts. 

Now first what is mediator, its one of the basic component of SOA suite, which works as a router between the service calls and BPEL or any other component connected to Mediator.

 Now first we are taking content based routing, here based on the content of payload we mediator will  decide which BPEL/Service to be called.


 For this we are taking a very simple example of payload and we are first designing the WSDL to allow four different operations

1. Add
2. Substract
3. Delete
4. Multiply



Application Creation.

1. First we need to create an SOA application. Open the jdevelper and select for SOA Application.



2.  Now give name as "SOAOperationBasedRoutingDemo"  and then say next.



3. Now name the project "MediatorOperationBasedRoutingDemo" and then click next. You can choose your own name also, map the instructions accordingly.


4. Now choose the empty composite and then then finish it will create an empty composite.



Schema Creation 


1. Now select the schema and then say -> New --> Xml Schema and say OK.


2. Now name the schema as mediatorDemoSchema.xsd and say finish. you can change the namespace or can leave it.


4. Now create one request and one response element as give below, its a simple xsd. You can copy the schema from our project also.


5. Now we are going to create wsdl which is having two operations.


6. Now  name the wsdl and MedatorOprationsWSDL.



8. Once WSDL is created then you need to  create the message first name the message as "mathOperationRequestMessage".  then create the part and select the referece value as MathRequest from the schema we created.





9. Once created then we need to create one more message as mathOperationResponseMessage. Choose the porty type.




10.Once done we can create two opreations inside it, name it as given in the two images.





Mediator Creation

  1. Now place the mediator from the component palate to the Composite and then we can choose wsdl now choose the wsdl from the location where we have created.






2. Let the service to be exposed as SOAP to be checked.



3. It will create the mediato like given below with two operations.




BPEL Creation

1. Now we can place the BPEL from the component palate to composite, name is AdditionBPELProcess and then choose template as :Synchronous" and then select input and putput type from the xsd.





2. It will look like with all the parameters. now say ok.
.

3. Once BPEL is created then attach the wire between the BPEL and mediator it will ask you to select the operations select for the addition.





3. Now add a assign activity to BPEL and assign the sum of param1 and param2 to result and :"Success" string to status.





4. Complete assign will look like this.



5. Now go back to composite and add one more BPEL which is multiplicationBPEL.


6. Choose the same parameters as we did for the last BPEL and final outcome will look like below and thenclick ok , which will create one more MultiplicationBPEL.


7. Now add the multiplication BPEL to Mediator and select the operation as multiplication.



8. Now add a assign activity and assign multiplication to the result as given below.




Once you are done your process are ready for the deployment.  Deploy the composite to the integrated server and test it.


Testing.

1. Select the operation as addition and then provide both the parameters,  then click on test.






2. You can change the operations now and can choose the operation as multiplication now the multiplication BPEL will be executed.






Download the sample

You can download the sample from the location.





Exercise 


1. Add one more operation to the Mediator, which is subtraction.



Please let me know the feedback. Happy to hear feedback from you.






Sunday, 16 October 2016

Correlation in SOA Process 12c

Correlation in SOA Process.




In most of the process,process run like an  standalone  processes. But some time we want to change the process behavior in the middle of the process.

 Like we start the recruitment of an employee and process of employee creation been started. In between process will stop and will run further once we provide any input from the service which is for the background check.

Other requirement is webservice addressing, like from BPEL if we are calling a service A and then A will call service B and we want B to provide response back to initiator BPEL process, then we need concept of webservice addressing.

Hence until we received any input from the other service,  first service will stop. The other challange in this is there are multiple may be running, hence to correlate we need some key. In this example we can take employeeId as a key for the correlation.


Hence collaboration set should be unique and BPEL process based on the correlation id decide which process it need to map.

Now taking the example, lets first create the Schema and then WSDL, post that we will create the BPEL process.


1. Schema :-  In this example we are using  a very simple schema of employee and his background check.  Candidate Id is been used as a key, which will be unique for all the processes.   Please copy the EmployeeBackgrpundCheck.xsd from the main process.



2. Creating the Application,

2.1)  From the jdev -> File -> New Application and choose for a SOA application


2.2) Provide a name to the application "SOACorrlationDemoApp". 


2.3 Provide the project name and say next


2.4 Choose empty composite and provide the composite name. as "EmployeeCreationCheckCorrlation".


2.5 Now create the schema first, you can create the schema or copy if from our project, which is available for download copy the file "EmployeeBackgrpundCheck.xsd" to your project.



BPEL Creation 

1. Now Drop BPEL from the components to composite and name is EmployeeCreationCheckCorrlation, change the property to asynchronous.





2.  Now BPEL creation is completed and we need to add one message for invoking the service in middle hence open the WSDL which is just now created and add a message type as given below.


3.  Now add a payload part and add the message element.


 4. Now add a new port for the check results,  service and then add the operations and select the backroundcheckresult element type.




5, Now drop a soap service on the exposed side and select the wsdl we modified and choose for the new port type, which is employeeCheckResult.



5. Now add the wire between the BPEL and new SOA service we exposed.



This has completed and we exposed first service as initiator and then second as a service for the correlation.

Now its done and we need to complete the BPEL and modify the correlation.


Correlation and BPEL Completion.

1.  Once its done then create the following


1. Assign activity, just to assign success to the payload.


2. Now add a receive activity, and select for the partner link and choose for employeeBCCheckRequest.


4. Add the input variable as given in the below picture.


5. once done add a if block assign failure if background check send a fail status.


Now our process is complete and we are ready to correlate both the service. click the first activity and right click over it and select for the create corrlation and follow the screenshots as given


Create a new Corrlation set and name it as given below. 


Now select the activity and say initiate = yes.


Now select for the element which will be used as a key for the corrlation.


Now select for the activity which will correlate, in this case our receive activity will correlate with a already running process.


 Please check if you have both the aliase created.




Once done your process is ready for the deployment.


Deploy this process on the weblogic server  and then first initiate the main process using the payload


you can also use following endpoints to test in the SOAPUI.


1. WSDL for the invoking
http://localhost:port/soa-infra/services/default/EmployeeCreationCheckCorrlation/employeecreationandbccheckdemo_client_ep

2. WSDL for correlation.



In soapui provide the message as given below and here candidate id is the key, which relate between two processes.

Request 1.



request 2.



End result.
    




Download 

Please use the link to download the sample.  Download Link



Exercise

1. Complete the Sample with DB adapeter to insert a employee if background get successfull,

2. Add email id and use it for the correlation.


Please provide your feedback, we will try to improve.