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. 







Thursday, 22 September 2016

Rules In SOA 12C

Rules in SOA 12c



In some of the business cases, you may need a changing environment, where your decision can be change over the time and also a medium to complex decision taking mechanism.  This entire system is running on some 3-4 basic settings, lets explore them one by one.  This is our first post over the rules and we will continue to explore more deeper into further posts. In this post we are trying to complete a solution, where we are deciding that no employee should be having a salary of more then 10000 and less then 1500.

We agree that it can simple be achieved using the if block but we tried to keep the example simple to understand. 


1. Facts. 

If in a system you want to take decision there could be some data which is static and dynamic. Like if want to process an employee then salary of a new employee we are entering is dynamic data.  Then the input data which comes to rule from the BPEL or mediator knows as fact. Its the data which is input to the decision. 

    a)  XML Facts :- 
              Data generated from the xml schema is known as fact. this include the data which is coming from the BPEL or you can add any new structure.

   
   b) Java facts  and ADFC Facts :-
        Will be discussed in the future posts.

 
2. Functions. 
     These functions can be created using the scripting canvas provided to you and later can be used to in the rule for the data manipulation.


3.  Gobals :- 
    These are variables, which can be used inside the rules to deal with the data. In this example we have created two constants, which are min and max salary.


4. Decision Function :- 

    Decision functions are different functions or set of rules, you can build. Normally when you create a rule a decision function be created automatically. You can create more also group already built rules in the decision function.



5. Translations :-

   With rules if you want to change the language of any output, then you can use translations. But use is limited.


6. Data Explorer :-

  It tells you all the data type been used in the Rules.


Now coming to example, where we are using a rule to decide salary, if minimum or maximum salary restriction reach.



1. Create a simple SOA application SOAEmployeeDemoApp with empty Composite SOAEmployeeDemoProj project,  There are several parameter in the xsd but we are considering only.



2. Create a SOA Project and give the name as given below.



3. Use empty Composite  for the project to call.



4. Once done then add a BPEL process on the composite, exposed it as a service. Before creating the BPEL process copy the schema from the given project.




5. Now from the side take the rule and add it to the composite. Give the name as given below also choose input and output as a same type. as given below.




6. Once done OK your rules are create with all the appropriate files, now its time to configure a simple rule.

   a. Add two Globals Min and Max salary stating values 500 and 15000.
   b. Add a rule as given below to check min salary and modifying the salary if less then the min salary.





7. Once its done then we need to call it from the BPEL, add rule activity from the BPEL and then add inputs and ouputs as given in the next picture.


  8. Now add the input values to the parameters.


 9. Map the output values of the rules to BPEL variables.


10. This is how entire process will look like.






Running 

1. Now deploy this BPEL process on SOA 12c Server.  and then open the composite for testing. provide input only salary should be less then 500.



2. Post testing it will give salary as 500.


3. This will be error trace for the process.




 Download 

 Please download the application from the link.



 Exercise.

 1. Add a new rule stating salary is more the 15000 then it should limit to 15000.




In the next post we will take ValueSet and bucketsets in rules.