Passing Parameters from BPEL to XSLT

Oracle BPEL can pass parameters defined within an XSLT. This is convenient as normally the XSLT maps are not able to access variables that are defined explicitly in BPEL.

Its pretty easy to do … just follow these steps:

1. The parameters that require to be passed to the XSLT should adhere to the following schema:

Parameter Schema

Parameter Schema

I have used a minOccurs of 2 but you may not need it …

2. Now create a variable based on this schema . Let us call it parametersVar.

create variable for parameter

create variable for parameter

3. Now set values to this variable. In this example I have taken the values from the input. A transform activity based on the xsl setParameters.xsl sets the input. you may also choose to hardcode the values.

populate the parameter variable

populate the parameter variable

4.Now create another transform activity called callXSLT that maps the input to the output. This xslt defines two parameters viz. param1 and param2. The XSLT simply concats the two parameters and assigns to the output.

XSLT with Parameters

XSLT with Parameters

5. The BPEL process should now look like this:

BPEL process design view

BPEL process design view

6. Now open this BPEL process in source mode and edit the

<from expression=”ora:processXSLT(‘callXSLT.xsl’,bpws:getVariableData(‘inputVariable’,’payload’))

to include the parameters as this:

<from expression=”ora:processXSLT(‘callXSLT.xsl’,bpws:getVariableData(‘inputVariable’,’payload’),bpws:getVariableData(‘parametersVar’))”/>

The BPEL source should now look like this:

<?xml version = “1.0” encoding = “UTF-8″ ?>
<!–
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Oracle JDeveloper BPEL Designer

Created: Mon Sep 08 13:47:27 IST 2008
Author: sphukan
Purpose: Synchronous BPEL Process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
–>
<process name=”paramsFromBPELToXSLT”
targetNamespace=”http://xmlns.oracle.com/paramsFromBPELToXSLT&#8221;
xmlns=”http://schemas.xmlsoap.org/ws/2003/03/business-process/&#8221;
xmlns:bpws=”http://schemas.xmlsoap.org/ws/2003/03/business-process/&#8221;
xmlns:xp20=”http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20&#8243;
xmlns:ids=”http://xmlns.oracle.com/bpel/services/IdentityService/xpath&#8221;
xmlns:ldap=”http://schemas.oracle.com/xpath/extension/ldap&#8221;
xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221;
xmlns:client=”http://xmlns.oracle.com/paramsFromBPELToXSLT&#8221;
xmlns:ora=”http://schemas.oracle.com/xpath/extension&#8221;
xmlns:xref=”http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions&#8221;
xmlns:hwf=”http://xmlns.oracle.com/bpel/workflow/xpath&#8221;
xmlns:aia=”http://www.oracle.com/XSL/Transform/java/oracle.apps.aia.core.xpath.AIAFunctions&#8221;
xmlns:ns1=”http://schemas.oracle.com/service/bpel/common&#8221;
xmlns:ehdr=”http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions&#8221;
xmlns:bpelx=”http://schemas.oracle.com/bpel/extension&#8221;
xmlns:orcl=”http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc”&gt;
<!–
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PARTNERLINKS
List of services participating in this BPEL process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
–>
<partnerLinks>
<!–
The ‘client’ role represents the requester of this service. It is
used for callback. The location and correlation information associated
with the client role are automatically set using WS-Addressing.
–>
<partnerLink name=”client” partnerLinkType=”client:paramsFromBPELToXSLT”
myRole=”paramsFromBPELToXSLTProvider”/>
</partnerLinks>
<!–
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
VARIABLES
List of messages and XML documents used within this BPEL process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
–>
<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:paramsFromBPELToXSLTRequestMessage”/>
<variable name=”outputVariable”
messageType=”client:paramsFromBPELToXSLTResponseMessage”/>
<variable name=”parametersVar” element=”ns1:parameters”/>
</variables>
<!–
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ORCHESTRATION LOGIC
Set of activities coordinating the flow of messages across the
services integrated within this business process
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
–>
<sequence name=”main”>
<!– Receive input from requestor. (Note: This maps to operation defined in paramsFromBPELToXSLT.wsdl) –>
<receive name=”receiveInput” partnerLink=”client”
portType=”client:paramsFromBPELToXSLT” operation=”process”
variable=”inputVariable” createInstance=”yes”/>
<!– Generate reply to synchronous request –>
<assign name=”setParameters”>
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression=”ora:processXSLT(‘setParameters.xsl’,bpws:getVariableData(‘inputVariable’,’payload’))”/>
<to variable=”parametersVar”/>
</copy>
</assign>
<assign name=”callXSLT”>
<bpelx:annotation>
<bpelx:pattern>transformation</bpelx:pattern>
</bpelx:annotation>
<copy>
<from expression=”ora:processXSLT(‘callXSLT.xsl’,bpws:getVariableData(‘inputVariable’,’payload’),bpws:getVariableData(‘parametersVar’))”/>
<to variable=”outputVariable” part=”payload”/>
</copy>
</assign>
<reply name=”replyOutput” partnerLink=”client”
portType=”client:paramsFromBPELToXSLT” operation=”process”
variable=”outputVariable”/>
</sequence>
</process>

7. Save the file, validate and deploy the process.

8. Now initiate the process in Oracle AS and put the input as follows:

Initiate the BPEL Process

Initiate the BPEL Process

Notice that param1 and param2 are the parameters we defined earlier in the XSL file.

9. The output shows the result.

BPEL Process Flow Diagram

BPEL Process Flow Diagram

Output from the setParameters operation

Output from the setParameters operation

Thats all…enjoy!!!

Advertisements
Comments
4 Responses to “Passing Parameters from BPEL to XSLT”
  1. Shanty says:

    Hi Sandeep !!

    Thanks a lot for this awesome post.
    I need your valuable suggestion for the below error:
    XML-22045: (Error) Extension function error: Class not found ‘oracle.apps.aia.core.xpath.AIAFunctions’
    I am getting this error while trying to run the xsl containing the above class.
    I am using JDev 11g currently.
    Please do the needful.
    Thanks in advance.

    Regards,
    Shanty

  2. I am assuming you are trying to use some Oracle AIA custom functions. This error shows up when the custom functions are not registered on Oracle App Server. There is a patch for the same in Metalink. Check for AIA JDev extension functions, download the patch and apply ….

    Hope this helps …
    Cheers!!!

  3. Shanty says:

    Hi Sandeep!
    Thanks a lot for your valuable suggestions.
    The error is now eliminated.

    Regards,
    Shanty

  4. Madhav says:

    Hi Sandeep,
    Thanks for giving the solution.
    But even after doing the same, we are getting the following error.
    >>>>

    XPathExecutionError
    XPath expression failed to execute. Error while processing xpath expression, the expression is “ora:processXSLT(‘Transformation_5.xsl’,bpws:getVariableData(‘inputVariable’,’payload’),bpws:getVariableData(‘parametersVar’))”, the reason is message can’t be null. Please verify the xpath query.

    >>>>>
    Can you please provide any suggestions
    we using 10.1.3.4

    Thnaks,
    Madhav

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: