Go to page:
Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 Next
Building and Deploying
BPEL Designer offers direct compilation and deployment on the Oracle BPEL Server. This can be done from the toolbar or from the BPEL menu. In addition to building and deploying, we can also validate our project and open the BPEL Console:
(continued)
For more information about the BPEL Designer refer to Oracle documentation. In the next section we look at the Oracle-specific functions of the BPEL Process Manager. We will start with the Oracle-specific extension functions.
Oracle-Specific Functions
In Chapters 2 and 3 we saw that BPEL is very flexible with respect to the expression and query language. By default we use XPath 1.0; however, we can use any other language supported by the BPEL server. The idea behind this flexibility has been to open up BPEL for future versions of XPath (and XQuery).
XPath 1.0 does not provide all functions necessary to develop BPEL processes. Therefore, the BPEL specification defines additional functions such as getVariableData(), getVariableProperty(), and getLinkStatus(). Oracle BPEL Process Manager provides additional extension functions to simplify the development.
Note: Using these functions limits the portability of BPEL processes, because these functions will not be available in other BPEL servers.
Oracle extension functions are defined in the following namespace URI: http://schemas.oracle.com/xpath/extension. We will use the ora prefix for this namespace, which corresponds to the following XML declaration xmlns:ora="http://schemas.oracle.com/xpath/extension".
The extension functions are related to:
- Transformation and query support
- Data and array manipulation
- XML manipulation
- Date and time expressions
- Process identification
All Oracle-specific functions can be accessed using BPEL Designer's Function Wizard.
Transformation and Query Support
In real-world business processes we often have to match the schema of our XML document to the schema required by the partner web service. Consider our travel process example. Here we designed both the process and the partner web services, so we only had to perform minimal transformations for calling the Employee or Airlines web services. In real-world examples this will often not be the case and we will have to make more complex transformations.
To perform the transformations, we can use the BPEL <assign> activity. As this can be time consuming, Oracle provides an XSLT engine and an extension function through which we can activate the XSLT engine. This enables us to use XSLT to do more complex data transformations. Using XSLT is more appropriate than using <assign> because XSLT is the standard transformation language for XML. Also, sometimes we already have the stylesheets for transformation. This way we can easily integrate them into BPEL processes.
To activate the XSLT engine we use the ora:processXSLT() function. The function requires two parameters, the XSLT stylesheet and the XML input on which the transformation should be made.The result of the function is the transformed XML. The syntax is:
ora:processXSLT(
Usually we use this function within the <assign> activity, in the <from> clause. For example, to modify our travel process and make a more complex transformation to prepare the input for the Employee web service, we could use the XSLT engine, as shown in the following code excerpt:
<assign>
<copy>
<from expression="ora:processXSLT('employee.xslt',
bpws:getVariableData('TravelRequest',
'employee') )"/>
<to variable="EmployeeTravelStatusRequest" part="employee"/>
</copy>
</assign>
For this code to work we must create the employee.xslt stylesheet and deploy it with the process. For more information on XSLT please refer to http://www.w3.org/TR/xslt.
In addition to the XSLT engine, Oracle BPEL Process Manager also provides:
- An XQuery engine
- An XSQL engine
With the XQuery engine we can perform complex queries on XML documents, going beyond the capabilities of XPath. We can use the built-in XQuery engine through the ora:processXQuery() function. We have to provide the query template and the context XML on which the query should be performed:
ora:processXQuery(
We will use the function from the <assign> activity. Suppose we would like to create the EmployeeTravelStatusResponse with an XQuery. We would have to create the query and store it into the query.xq file and use the following code snippet:
<assign>
<copy>
<from expression="ora:processXQuery(query.xq',
bpws:getVariableData('EmployeeTravelStatusRequest',
'employee'))"/>
<to variable="EmployeeTravelStatusResponse" part="employee"/>
</copy>
</assign>
To process only a specific item, we can use the ora:processXQueryItem() function. The syntax is similar to ora:processXQuery(); here we have to provide the item:
ora:processXQueryItem(
For more information on XQuery please refer to http://www.w3.org/XML/Query.
In a similar way we can use the Oracle XSQL engine. It can be activated using theora:processXSQL() function. We have to provide the XSQL template and the input XML on which the query should be performed:
ora:processXSQL(
Data and Array Manipulation
Data manipulation in BPEL is done within the <assign> activity, where we can use XPath and BPEL functions in the <from> and <to> clauses. In addition, Oracle provides several custom functions that ease data manipulation considerably.
A very important aspect in data manipulation is arrays. In Chapter 3 we mentioned that arrays in BPEL are realized with XML elements, which can occur more than once. In XML schema they are identified with the maxOccurs attribute, which can be set to a specific value or can be unbounded (maxOccurs="unbounded"). The items are addressed with the XPath position() function, as shown in the following example:
<assign>
<copy>
<from variable="TicketOffer"
part="ticket"
query="/item[position()=1]"/>
<to variable="FirstOffer" part="ticket"/>
</copy>
</assign>
The short notation is:
<assign>
<copy>
<from variable="TicketOffer"
part="ticket"
query="/item[1]"/>
<to variable="FirstOffer" part="ticket"/>
</copy>
</assign>
Often we need to dynamically address the items. Instead of hard-coding the index we can use avariable, such as:
<variable name="position" type="xsd:integer"/>
We could then create the XPath query expression, store it in a variable, and then use this variable to address the desired item, as shown in the following example:
<assign>
<copy>
<from expression="concat('/item[',
bpws:getVariableData('position'), ']')"/>
<to variable="itemAddress"/>
</copy>
<copy>
<from expression="bpws:getVariableData('TicketOffer
bpws:getVariableData(
<to variable="SelectedOffer" part="ticket"/>
</copy>
</assign>
Alternatively we can use an Oracle-specific function called ora:getElement(). The function takes four parameters: variable name, part name, query path, and element index:
ora:getElement(
The previous example using this function would look like this:
<assign>
<copy>
<from expression="ora:getElement('TicketOffer', 'ticket', '/item',
bpws:getVariableData('position'))"/>
<to variable="SelectedOffer" part="ticket"/>
</copy>
</assign>
We usually dynamically address items in loops using the <while> activity. To determine the number of items (array size), we can use the Oracle-specific function ora:countNodes(). The function returns the number of items as an integer and takes three parameters: variable name, part name, and query path (the last two parameters are optional):
ora:countNodes(
To count the number of ticket offers in our example we could use the following code:
<assign>
<copy>
<from expression="ora:countNodes('TicketOffer',
'ticket', '/item')"/>
<to variable="NoOfOffers"/>
</copy>
</assign>
To append an item to the existing items we can use the Oracle-specific function ora:addChildNode(). The syntax of the function is:
ora:addChildNode(
To add a new ticket offer to the existing offers we can use the following code:
<assign>
<copy>
<from expression="ora:addChildNode(
bpws:getVariableData('TicketOffer', 'ticket'),
bpws:getVariableData('NewOffer'))"/>
<to variable="TicketOffer" part="ticket"/>
</copy>
</assign>
To add more than one item to the existing items, Oracle provides another function called ora:mergeChildNodes(). The syntax of the function is:
ora:mergeChildNodes(
For example, to add a several new ticket offers to the existing offers we use the following code:
<assign>
<copy>
<from expression="ora:mergeChildNodes(
bpws:getVariableData('TicketOffer', 'ticket'),
bpws:getVariableData('AdditionalOffers'))"/>
<to variable="TicketOffer" part="ticket"/>
</copy>
</assign>
We have seen that Oracle-specific functions simplify array management considerably. Next we look at functions related to XML manipulation.
Go to page:
Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 Next