Wednesday, 9 November 2011

Lesson04-Human Workflow

image
Continuing from earlier Mediator example, lets extend our use-case to include .
MyDel handles two types of orders: Normal and Express. Normal orders are processed only after order items arrive in the Depot. Depot manager then logs into Workflow and releases the order to be sent for further processing in Order Management system. However, Express orders are directly sent for processing into Order Management system.
In this example, we are going to route orders through an Order Router that will route Express and Normal orders to Order Management service and Human Workflow respectively. Depot Manager logs into Workflow system to release order for the goods received in Depot. Released orders will be written to Order Management system.
Please use the Human Workflow JDeveloper Template if you want to implement this project on your own. Complete JDeveloper project is also available from Downloads section.
In previous Mediator Example, the process we built is shown below:
Mediator Example
Drag and drop a Mediator component from Component Palette on to Components lane of composite.xml. Name it OrderRouter and select “Define Interface Later” template.
orafmwschool_hwflow02
Delete the link between OrderFTPABCS and OrderABCS as shown below.
orafmwschool_hwflow04
orafmwschool_hwflow06 orafmwschool_hwflow05
Similarly, delete the link between OrderWSClientService and OrderABCS.
orafmwschool_hwflow08
Connect OrderWSClientService and OrderRouter.
orafmwschool_hwflow10
Connect OrderFTPABCS and OrderRouter. Then connect OrderRouter and Order ABCS.
orafmwschool_hwflow13
Connect OrderFTPABCS and OrderRouter. Then connect OrderRouter and OrderABCS. So far, we introduced OrderRouter before OrderABCS in order to branch request to Workflow where appropriate.
Lets proceed with workflow creation. Drag and drop “Human Task” component from Component Palette. Name it “OrderApprovalTask”. Specify “http://orafmwschool.com/training/workflow/OrderApprovalTask” as Namespace.
orafmwschool_hwflow16
In General section, enter details as shown below.
orafmwschool_hwflow19
In Data section, select OrderDetailsRequest element as shown below.
orafmwschool_hwflow20  orafmwschool_hwflow21orafmwschool_hwflow22
In Assignment section, double click on <Edit Participant> and enter weblogic user as shown below.
orafmwschool_hwflow24  orafmwschool_hwflow25
orafmwschool_hwflow26
This completes the creation of Human Task. We need to link this to BPEL process in order to execute it. Lets drag and drop a BPEL process from Component Palette. Enter values as shown below. Input and Output variables can be chosen from Type Explorer by clicking on magnifying icon.
orafmwschool_hwflow29
Double click on ApprovalProcess to open BPEL design window. Drag and drop a “Human Task” component as shown below.
orafmwschool_hwflow31
Select OrderApprovalTask in Task Definition field.
orafmwschool_hwflow32
Select OrderDetailsRequest as Task Parameter.
orafmwschool_hwflow34
This will create OrderApprovalTask_1 component in BPEL that looks like below:
orafmwschool_hwflow66
OrderApprovalTask _1 can have three outcomes: NO, YES and Others. We need to invoke OrderABCS when outcome is YES. In two other cases, we will let the workflow return without performing additional tasks.
Lets drag and drop an invoke activity in “Task outcome is YES” branch and name is Invoke_OrderABCS. Select OrderABCS as Partner Link and its ReadOrder as an Operation. Also, click on “+” sign to create automatic input and output variables.
orafmwschool_hwflow67
Drag and drop assign activity in “Task outcome is YES” branch and name is Assign_Input_OrderABCS. Assign payload from BPEL’s input variable to OrderABCS.ReadOrder’s input variable.
orafmwschool_hwflow68 orafmwschool_hwflow69
Similarly create Assign_Output_OrderABCS activity and assign response from OrderABCS to BPEL’s output variable.
orafmwschool_hwflow70 orafmwschool_hwflow71
This completes the OrderApproval BPEL process. Lets go back to composite.xml. Link OrderRouter with OrderApprovalProcess. Delete link between OrderApprovalProcess and the default client created by JDeveloper.
orafmwschool_hwflow41
Link OrderApprovalProcess with OrderABCS as shown below.
orafmwschool_hwflow43
We need to create routing rules to send all non-EXPRESS orders to Workflow and send EXPRESS orders to Order Management system. Double click OrderRouter mediator and go to the Routing Rules section.
orafmwschool_hwflow74
Create following routing rules for OrderABCS and OrderApprovalProcess respectively.
orafmwschool_hwflow72
orafmwschool_hwflow73
HumanWorkflowExample is now ready to be deployed.
orafmwschool_hwflow50
Lets test the composite now. Create one NORMAL and one EXPRESS order in Order.txt and place it in file polling directory.
orafmwschool_hwflow53
This creates two instances of HumanWorkflowExample. One instance, with EXPRESS order entry, will directly write information to Order Management system where as the other entry creates a workflow that awaits Depot Manager’s approval.
orafmwschool_hwflow59
Click on the process Instance ID that is in “Running” stage. Process flow for this specific instance will be shown in a pop up window. We can see the process is waiting for Human Worflow stage.
orafmwschool_hwflow61
Click on the “OrderApprovalTask”. In the above screenshot, its the link on the left side of “Human Workflow Component”. From the next screen, click on “Go To Woklist Application” and login to workflow application. In my case, user name is “weblogic”. We can see an order entry pending for Approval. Click on “Actions” and then “Yes”.orafmwschool_hwflow62orafmwschool_hwflow63
Come back to HumanWorfkflowExample in Enterprice Manager and check that process is now complete.
orafmwschool_hwflow65
Click on completed process instance, in this case 150010, to see process flow. We can see that OrderRouter invoked OrderApprovalProcess when order type is NORMAL. Once approved, OrdreManagementService is invoked through OrderABCS.
orafmwschool_hwflow76
We can also see BPEL process flow by clicking on OrderApprovalProcess. Explore Audit Trail and Flow tabs from the next screen.orafmwschool_hwflow77orafmwschool_hwflow78
Hope this lessons helped you appreciate Human Worflow features better. I personally prefer BPEL workflow to traditional workflows because of the ease and elegance.
Please use the Human Workflow JDeveloper Template if you want to implement this project on your own. Complete JDeveloper project is also available from Downloads section.

Lesson03-Meta Data Store Archives

SOA Suite 11gR1 has a provision for sharing SOA artifacts through – Meta Data Store. This facilitates greater re-use of SOA artifacts such as XML Schemas, EBMs, WSDLs, Fault Policies, Rule repositories and Service Data Objects (SDOs) among others. can be file-based or database-based. Here are the steps to create and use file-based in JDeveloper.

MDS is created under <jdeveloper-home>/integration/seed directory. Default folder “soa” is used to store common system soa artifacts. All custom artifacts are supposed to be stored under a folder called “apps”, since this folder already exists in server.

Create directory structure under apps folder. In this example, I’ve created folder structure ../apps/com/wordpress/orafmw/training/xsd to store XML schema files. This ideally should match your schema structure.
image

In JDeveloper, expand Descriptors/ADF META-INF and open adf-config.xml.

image

Create an entry for metadata store location.
<metadata-namespaces>
<namespace metadata-store-usage=”mstore-usage_1″ path=”/soa/shared”/>
<namespace metadata-store-usage=”mstore-usage_2″ path=”/apps/com”/>
</metadata-namespaces>
Specify MDS storage location.
<metadata-store-usage id=”mstore-usage_2″>
<metadata-store class-name=”oracle.mds.persistence.stores.file.FileMetadataStore”>
<property value=”D:\PROGRAMS\OracleMiddleware11g\jdeveloper\integration” name=”metadata-path”/>
<property value=”seed” name=”partition-name”/>
</metadata-store>
</metadata-store-usage>
Use defined artifacts directly from MDS.
<xsd:schema elementFormDefault=”qualified”>
<xsd:import namespace=”http://orafmw.wordpress.com/training/mediator/ebm/OrderProcessing”
schemaLocation=”oramds:/apps/com/wordpress/orafmw/training/xsd/OrderProcessingEBM.xsd“/>
</xsd:schema>
Deploy MDS Repository to Weblogic Server
First, we need to create JAR file bundle to include schemas we need. Then we need to include this jar file into a SOA bundle that can be deployed to the SOA Server.
Create Generic Application – MediatorMetaData
orafmwschool_mediator_68
orafmwschool_mediator_69
Create a project – MediatorLib
orafmwschool_mediator_70
Right click on MediatorLib and select New –> Deployment Profile –> JAR File
orafmwschool_mediator_73
Enter mediatorlib as the deployment profile name.
orafmwschool_mediator_74
In the JAR deployment properties dialog, click on Contributors, click on Add button and select apps directory from JDeveloper seed location – <jdeveloper_home>/integration/seed/apps.
orafmwschool_mediator_75
orafmwschool_mediator_76
orafmwschool_mediator_77
orafmwschool_mediator_78
Click on Filters and select the schemas you would like to be deployed.
orafmwschool_mediator_79
Click on OK. This completes creation of JAR file. We now need to create an application deployment profile to install these schemas in SOA Server.
Right click on MediatorMetaData application and select Deploy –> New Deployment Profile. Select “SOA Bundle” as Profile type.
orafmwschool_mediator_80
Enter mediatorlib for Deployment Profile Name. From the properties dialog, open Dependencies and select mediatorlib.
orafmwschool_mediator_82
To deploy MediatorLib to SOA Server, right click on MediatorMetaData and select Deploy –> mediatorlib.
orafmwschool_mediator_83

Lesson02-Mediator

Let us see how we can utilize features of component (previously known as Oracle ) to implement the following use-case.
MyBay is a fictious online store that lets customers view and place orders over the internet. MyBay utilizes its logistics partner MyDel to ship orders to customers. IT systems to handle order processing are created and maintained by MyDel.
MyBay can post order information to MyDel through MyBay’s online portal using Webservices. MyBay can also batch orders and transfer the file across to MyDel using FTP.
image
Step 1: Design Enterprise Business Objects (EBO)
First step is to create our canonical model. We need to carefully think through data, task and functional elements so as to maximize re-usability and minimize data transformation.
Namespace: Qualify schema with a meaningful namespace. Usually this takes the form of http://<your_website_url>/<organization>/<function>/xsd/
In our case, we’ll name it http://orafmwschool.com/training/mediator/xsd/OrderProcessing
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://orafmwschool.com/training/mediator/xsd/OrderProcessing"
targetNamespace="http://orafmwschool.com/training/mediator/xsd/OrderProcessing"
elementFormDefault="qualified">
Schema Elements: At a very minimum, we need information about selected item, transaction date and address it needs to be shipped to.
<xsd:element name="orderDetails" type="tOrderDetails"/>
<xsd:complexType name="tOrderDetails">
<xsd:sequence>
<xsd:element ref="itemDetails"/>
<xsd:element ref="transactionDate"/>
<xsd:element ref="shipTo"/>
</xsd:sequence>
</xsd:complexType>
Complete Order.xsd schema can be found here. Copy this XSD file into “xsd” directory of the project.
Step 2: Design Enterprise Business Message (EBM)
Enterprise Business Message is a wrapper over EBO. It usually combines one or more elements from EBO to create a meaningful input and output messages for the SOA services. In the current example, we’ll create two message elements: OrderDetailsRequest and OrderDetailsResponse. However, we need to refer to Order.xsd in order to use elements defined in the EBO.
<xsd:import
namespace="http://orafmwschool.com/training/mediator/xsd/OrderProcessing"
schemaLocation="Order.xsd"/>
<xsd:element name="orderDetailsRequest" type="tOrderDetailsRequest"/>
<xsd:complexType name="tOrderDetailsRequest">
<xsd:sequence>
<xsd:element ref="ord:orderDetails"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="orderDetailsResponse" type="tOrderDetailsResponse"/>
<xsd:simpleType name="tOrderDetailsResponse">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="SUCCESS"/>
<xsd:enumeration value="FAILURE"/>
</xsd:restriction>
</xsd:simpleType>
Complete OrderProcessingEBM.xsd can be found here. Copy this file to “xsd” directory of the project.
Step 3: Design abstract WSDL interface
Next step is to create an abstract Webservice interface that can be used in SOA services. In our case, we shall create two message elements: OrderDetailsRequestMessage and OrderDetailsResponseMessage.
<message name="OrderDetailsRequestMessage">
<part name="payload" element="ebm:orderDetailsRequest"/>
</message>
<message name="OrderDetailsResponseMessage">
<part name="payload" element="ebm:orderDetailsResponse"/>
</message>
Now that we have request and response messages created, we shall create an operation that consumes these messages.
<portType name="WSReadOrder">
<operation name="ReadOrder">
<input message="tns:OrderDetailsRequestMessage"/>
<output message="tns:OrderDetailsResponseMessage"/>
</operation>
</portType>
Complete OrderProcessing.wsdl can be found here. Do observe the xsd import element to import schema from MDS.
Step 4: Creating SOA Composite
Shown below is the snapshot of the composite we are eventually going to create. On the left side of the picture, you can see two services:
  1. Service to read order details from File. OrderFTPABCS will then transform order records into canonical form before passing them to OrderABCS.
  2. Webservice that external customers can invoke to post order details. These details are read directly in canonical form.
On the right side of the picture, we can see OrderManagementDBAdapter service that updates order details into Order Management Database. OrderABCS acts as a glue between all these services.
image
Proceed to Mediator Example Implementation.

Lesson01-HelloWorld Archives

We are going to learn how to create our first “Hello World” process in Oracle SOA 11g today. It presumes Oracle SOA 11g is installed and started. Also, JDeveloper should have composite editor plugin installed.

Open JDeveloper 11g (11.1.1.3.0). If not already downloaded, you can get it from http://www.oracle.com/technology/software/products/jdev/htdocs/soft11.html Create a new Generic Application and name it SOATrainingSamples.
image
image
Click Next. In the next screen, specify New Project Name as HelloWorld. From available technologies, select SOA. This will import SOA relevant libraries into our project.

From next screen, select Composite with option. There are other composite options available, which we’ll explore in other samples.

image
Click Finish. This will prompt a “Create BPEL Process” screen. Name BPEL process as HelloWorldProcess. Select “Synchronous BPEL Service” template. Click OK.

image
JDeveloper creates HelloWorldProcess BPEL components and displays corresponding BPEL process.

image
From list of activities on the right hand navigation pane, lets drag “Assign” activity and drop between “receiveInput” and “replyOutput” activities.

image
Double click on “Assign_1″ activity and open it. Select “Copy Operation” from this screen.

image
Copy following expression into Expression Field. concat(‘Hello ‘, bpws:getVariableData(‘inputVariable’,'payload’,'/client:process/client:input’))

This can also be created from XPath Expression Builder. Assign this expression to “outputVariable” as shown above and click OK.

image
Compile BPEL process by clicking on “Make HelloWorld.jpr” link as shown below:

image
Ensure BPEL process is successfully compiled. To deploy to Weblogic server, right click on “HelloWorld” from left side navigation and select Deploy -> HelloWorld. Following images show sequence of steps to deploy BPEL executable.

image

image
image
Connection to SOA Server needs to be created beforehand. In this example, a connection named SOAServerConnection was already created.
image
image

A successful deployment message is displayed at the bottom of JDeveloper window.

image
Next, let us check the deployed process through Weblogic’s EM console. Open http://localhost:7001/em. Drill down to “default” domain from SOA node on the left side navigation bar.

image
Select “HelloWorld [1.0]” process and click on “Test” service.
image
Under “Input Arguments” section, we can see “input” as one of the fields of payload. Enter “World” in input field and click on “Test Web Service”.image

Input payload can also be seen in XML format by selecting “XML View”.
image
Response will have “Hello” prefixed to our input string “World”.
image
This completes our Hello World process.

What is Fusion Middleware?

consists of several Oracle products, built over the years and recently acquired, that will help build end to end solutions. Oracle has been attempting to bring all these products under one roof. With recent release of 11g R1, I must say that it has managed to do it pretty well.
Oracle Fusion Middleware provides fully integrated products that can be divided into four important categories:
  1. Data and Application Layer: Products in this category help build integration with various databases, legacy/custom applications and ERP products.
  2. Business Process Layer: Products in this category utilize the integrations built in the data & application layer to create re-usable orchestrated services.
  3. User Interface Layer: Products in UI Layer will assist in creating sophisticated user interfaces supporting multiple delivery channels such as web, mobile etc.,
  4. Identity Management Layer: This is the security backbone of entire Fusion Middleware. We can easily plug-in authentication, authorization in standalone and/or distributed server environment. 
It is important to note that most of the products in each of these layers can also be used independently. But major value addition of Fusion Middleware is that most of these products are pre-integrated, creating grater synergy and re-usability.
Given the no. of products involved, this blog focuses on the backbone of Fusion Middleware: Business Process layer.
Oracle SOA Suite 11g
Oracle 11g is the product set for Business Layer. Individual constituents of Oracle and their description given below:
Oracle BPEL Process Manager: BPEL stands for Business Process Execution Language. It is a XML based declarative language that can be used implement end to end business processes. Basic building block of these processes is a service, which could be a web service. BPEL utilizes various adapters to service enable legacy and custom applications before consuming them in processes. BPEL also provides human workflow that has variety of uses.
Oracle Service Bus: OSB is an enterprise level service bus that was originally part of Weblogic before acquisition. OSB offers very useful features for service virtualization, canonical models and very efficient payload transformations. OSB is normally used to complement Oracle BPEL Process Manager.
Oracle Business Activity Monitoring: BAM is a real-time service monitoring tool that can be used to track an end to end process created by BPEL/OSB. BAM offers real-time dashboards that can be help diagnose potential bottlenecks in the processes before they occur. BAM can be easily plugged into BPEL PM using simple integration.
Oracle Business Rules: As the name suggests, its a product to create and use business rules. This can act as central repository for various rule artefacts and thus facilitate greater re-usability. It can be easily integrated with rest of Fusion Middleware products.
Oracle B2B Integration: Used to connect with trading partners using industry standard protocols such as RosettaNet, EDIFACT etc., It can interface with E-Business Suite using XML Gateway and rest of Fusion Middleware using IP Queues.
Oracle Complex Event Processing: CEP provides architecture for creating, processing and publishing events in an enterprise to create an event driven environment.
Together, above products can be used to define and implement Service Oriented Architecture.

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...