Monday, November 1, 2010

Customizing standard Input output of BPEL Process

Modifying Input XSD:
BPEL designer by default uses string for input as well as output. while dealing with complex interfaces we need to update input and output structure in such a way that it will meet all requirements. By default the schema looks like below. 
<schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns="http://www.w3.org/2001/XMLSchema"> <element name="DatabaseToFileAdapterProcessRequest"> <complexType> <sequence> //Input Element <element name="input" type="string"/> </sequence> </complexType> </element> //Output Element <element name="DatabaseToFileAdapterProcessResponse"> <complexType> <sequence> <element name="result" type="string"/> </sequence></complexType> </element> </schema>
The example I have shown here is to take ProjectName, Status and Role as input and after querying database it will show other project details like hostname,port, location,domain etc. Please refer below Figure 1 and Figure 2 for input and Output.
image  Figure 1
image
Figure 2
Figure 1 is used to describe input and Figure 2 is used to describe Output format.
we can edit “DatabaseToFileAdapterProcessRequest” element like below instead of a simple string.
image
After querying database fetched data structure looks like below.
image
Figure 2
Our next step will be incorporating those structures in BPEL file by Creating variables and using those variables in rest of the files. Please note down below things
  • Make sure that used targetnamespace for xsd also present in BPEL process. Check Process section of the BPEL process for below entry
    <process name="DatabaseToFileAdapter" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns:client="http://xmlns.oracle.com/DatabaseToFileAdapter"
  • Make sure Input and Output variable is referring modified input and output element of xsd via default message types of wsdl.
    <variables> <!-- Reference to the message passed as input during initiation --> <!-- Reference to the message that will be returned to the requester--> <variable name="inputVariable" messageType="client:DatabaseToFileAdapterRequestMessage"/> <variablename="outputVariable" messageType="client:DatabaseToFileAdapterResponseMessage"/> </variables>
  • messageType specified above refers message from WSDL file.Please see belowimage
  • Similarly the response message is using “DatabaseToFileAdapterResponse” element of the xsd.

Modifying BPEL standard WSDL:
  • Another way of achieving above objective is to import another xsd in wsdl file.
image
  • Make sure that the targetnamespace for imported xsd is used in WSDL definition as xml namespace prefix.
  • <definitions name="DatabaseToFileAdapter" targetNamespace="http://xmlns.oracle.com/DatabaseToFileAdapter" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:client="http://xmlns.oracle.com/DatabaseToFileAdapter" //below name space prefix needs to be added in order to utilize defined elements in that schema xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/SlectProjDetailsByProjName" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/">
  • We need to modify the Message element for “DatabaseToFileAdapterResponseMessage” in such a way that it will refer element belongs to imported xsd.
image
  • Make sure that InputVariable and OutputVariable referring to newly modified xsd rather than old default xsd.
image   expand the outputVariable node and make sure that you will get modified structure instead of the old structure.
image

No comments:

Post a Comment