oracle soa examples

22
[email protected] @johnxavierv—twitter [email protected] http://www.slideshare.net/xavierjohn4 07775991224 First Example in SOA using BPEL Simple example, it process the subject details and finally sends back grade as response. here is the explanation of application step by step. Step 1: client sending the subject details (s1, s2,s3,s4,s5) Step2 : we have to read the client data from exposed service, then we need to pass same data to external reference "total" operation. Step3 : output from "total" operation is input to "avg" operation Step4 : output from "avg" operation is input to "grade" operation. Step5 : Output from "grade" operation we need to send back to client. for doing above process we have to have following components/Services. Exposed Service - Entry point for my application External reference - to consume someone provided service BPEL - to do integration of Exposed Service and external reference. in this application we are using following BPEL Activities. Receive - to read the data from exposed service Reply - to send response back Invoke - to call external reference operation (for each operation we have to use one Invoke Activity) Assign - to transfer data between one variable to other variable. in this current example my process starts with "receive" activity and ends with "reply" activity. in between we are having 3 Invokes for 3 operations, and multiple assign activities to transfer the data. and the BPEL should look like bellow.

Upload: xavier-john

Post on 17-Feb-2017

101 views

Category:

Software


4 download

TRANSCRIPT

Page 1: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224First Example in SOA using BPEL

Simple example, it process the subject details and finally sends back grade as response. here is the explanation of application step by step.

Step 1: client sending the subject details (s1, s2,s3,s4,s5)Step2 : we have to read the client data from exposed service, then we need to pass same data to external reference "total" operation.Step3 : output from "total" operation is input to "avg" operationStep4 : output from "avg" operation is input to "grade" operation.Step5 : Output from "grade" operation we need to send back to client.

for doing above process we have to have following components/Services. Exposed Service - Entry point for my application External reference - to consume someone provided service BPEL - to do integration of Exposed Service and external reference.

in this application we are using following BPEL Activities. Receive - to read the data from exposed service Reply - to send response back Invoke - to call external reference operation (for each operation we have to use one Invoke

Activity) Assign - to transfer data between one variable to other variable.

in this current example my process starts with "receive" activity and ends with "reply" activity. in between we are having 3 Invokes for 3 operations, and multiple assign activities to transfer the data. and the BPEL should look like bellow.

Page 2: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Variables Receive - it contains only one Variable, that is input variable.Reply - it contains only one variable, that is output variable.Invoke - it contains two variables, input and output.

now we will see creation of first application step by step. After creation of Project we have to open composite.xml file, now we need to do following process

Step 1 : we have to create external reference based on URL. for creating external reference drag "Web Service" adapter from "Component Palette" ->"Service Adapters" and drop in "External Reference" area.

Page 3: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

once we drag and drop it opens the following popup, here we have to provide the "name", value for "WSDL URL" and then click "tab". if you want to copy the artefacts related to "WSDL URL" select the option "copy wsdl and its dependent artefacts into the project" (this is optional). and then click on "Ok".

it leads to following popup, in this Click on "Ok". This popup will be seen once we select the check box " copy wsdl and its dependent artefacts into the project".

Page 4: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Step 2 : now we need to create exposed Service, for creation of exposed Service, we need come up with XSD. for each operation in service we need to create two elements, one request and one response element. if my service contains 10 operations we have to create 10*2=20 elements.As per out requirement, our input element contains subject details and output element contain grade details. XSD should look like bellow.

creation of XSD - right click on "XSD" folder in project -> "All Technologies" -> "XML" -> "XML Schema" and click on "Ok"

Page 5: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

it leads to following popup, here provide the name of XSD as you wish and click on "Ok".

it creates "sample.xsd" ( I provided name as sample.xsd) in xsd folder. now create the elements based on your requirement. following is the source code for this application

<?xml version="1.0" encoding="windows-1252" ?>

Page 6: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org" targetNamespace="http://www.example.org" elementFormDefault="qualified"> <xsd:element name="input"> <xsd:complexType> <xsd:sequence> <xsd:element name="s1" type="xsd:int"/> <xsd:element name="s2" type="xsd:int"/> <xsd:element name="s3" type="xsd:int"/> <xsd:element name="s4" type="xsd:int"/> <xsd:element name="s5" type="xsd:int"/> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="output"> <xsd:complexType> <xsd:sequence> <xsd:element name="grade" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element></xsd:schema>

now using this XSD, we need to create "Exposed Service", for creating "Exposed Service" we need to drag "Web Service" adapter from "Component Palette" ->"Service Adapters" and drop in "Exposed Service" area.

it leads to following popup, here we need to provide "name", and click on "Generate WSDL from schema(s)"

Page 7: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

it leads to following popup, here we need to select "Interface Type", we have three types of interfaces.

Synchronous Interface Asynchronous Interface One-Way Interface

Based on requirement we will choose one of the above.now i am going with Synchronous Interface. we need to select input and output elements. click on "+" icon to select input and output elements.

Page 8: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224it leads to following popup, here we need to select browse for schema files, to select input and output elements.

it leads to following popup, here we need to select input element from "Project Schema Files" -> "sample.xsd" -> "input"

we need to repeat above process for output element also. after completion it looks like bellow

Page 9: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

then click on "Ok" and again click on "Ok".

Step 3 : Now drag BPEL component from "Service Components" and drop in "Component" area. select "BPEL 2.0 Specification", provide a name as you wish (in this example i am going with default name), select Template as "Define Service Later", and click on "Ok"

Page 10: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224Step 4 : Establish a communication between Exposed Service and BPEL Component using wire. select the transaction type as "required" and click on "Ok"

Step 5 : Establish a communication between BPEL component and External reference using "Wire". now mo composite look like bellow.

Step 6 : now double click on BPEL component, to add the activities. we have to add following activities.

Receive : Drag from BPEL Activities and drop in "Drop Activity Here"Reply : Drag from BPEL Activities and drop in "+"Invoke : Drag from BPEL Activities and drop in "+" (we have to add 3 Invokes)Assign : Drag from BPEL Activities and drop in "+" (Based on requirement we have to add multiple)

Page 11: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Receive – is to read client input data, it reads the data from exposed service. it has only one variable that is input variable. we need to drag and drop the receive activity in BPEL flow from BPEL Constructs -> Web Service, then we need to double click on receive activity, it opens the following popup.

We have to change following properties in Receive activity popup, based on our requirement.

Name (optional) : Receive1(Default), generally we need to come up with specific name.Operation : we need to select the Service operation.Create Instance : We need to select this to start the process. If we did not check it throws error while compiling code.Create Input Variable

Reply – to send response back to client through exposed service. It has only one variable that is output variable

we need to drag and drop the Reply activity in BPEL flow from BPEL Constructs -> Web Service, then we need to double click on Reply activity, it opens the following popup.

We have to change following properties in Reply activity popup based on our requirement.

Name (optional) : Reply1(Default), generally we need to come up with specific name.Operation : we need to select the Service operation.Create output Variable.

Page 12: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Assign – to transfer the data between one variable to other end variable. Using Assign activity we can transfer data between any variable to any variable like Input to Input, Input to Output, Output to Input, and Output to Output variables.

we need to drag and drop the Assign activity in BPEL flow from BPEL Constructs -> Basic Activities, then we need to double click on Assign activity, it opens the following popup.

Click on "General tab" in Popup

Page 13: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

After completion of above, Click on "Copy Rules" Tab to do the mapping

Page 14: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

if we do the mapping in Assign activity, for each mapping it is generating single copy Rule. it should look like bellow

<copy> <from>$Receive1_execute_InputVariable.part1/ns3:s1</from> <to>$Invoke1_total1_InputVariable.parameters/sub1</to></copy>

in the copy rule we have two tags, first one is "from" and second one is "to".from - holds the data of source Variableto - Is used to pass the "from data" to target variable.it is internally using XPATH to process the variable data.

Invoke – is used to invoke the external service or adapter. It has two Variables one input and output variable.

we need to drag and drop the Invoke activity in BPEL flow from BPEL Constructs -> Web Service, then we need to double click on Invoke activity, it opens the following popup.

We have to change following properties in Invoke activity popup, based on our requirement.

Name (optional) : Invoke1(Default), generally we need to come up with specific name.Operation : we need to select the Service operation.Create input/output variables.

Page 15: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Page 16: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

using input variable we pass input data to service, the response from service filled in output variable. likewise we have to repeat for "Avg" and "Grade" operations. he following are screen shots...

Page 17: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Page 18: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Now we need to transform the data between following variables

Receive_input - invoke_total_inputInvoke_total_output - invoke_avg_inputInvoke_avg_output - invoke_grade_inputInvoke_grade_output - Reply_output.

Page 19: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Page 20: oracle soa Examples

[email protected]@johnxavierv—twitter

[email protected]://www.slideshare.net/xavierjohn4

07775991224

Note : After mapping we need to Click on "Apply" + "Ok".