In this recipe, we will show the usage of the Transform
activity in JDeveloper. The XSLT mapping activity is exposed as the Oracle extension activity in JDeveloper.
Before we start with the recipe, we prepare an empty SOA composite project with the default synchronous BPEL process. We reuse the web service for querying about the available car. The input parameter presents a from
-to
date range, and the output of the web service call returns the available car at the specified date range. We also add the following two <assign>
activities:
In the JDeveloper environment, we pick the Transform
activity from the Oracle Extensions tab in the Component
Palette. We put the Transform
activity into the BPEL process as shown in the following screenshot:
We have just created a transformation activity in the BPEL process.
In the BPEL process we created previously, we had two assign activities. With the first one, we assign the values from the request variable of the BPEL process to the input variable of the invoke activity. With the second assign activity, we copy the content of the invoke activity output variable to the response variable of the BPEL process. This approach works perfectly in a relatively straightforward definition of the variable. For example, we can use the assign activity if the variables have the same name but different namespaces. This way, we deliberately violate the well-form of the XML document; however, we can get data without much of an effort.
We can also use the assign activity if the same definition of the request and response messages applies to the BPEL process as well as to the web service that is called from the BPEL process. However, if we have more complex structures of the variables, it is recommended that we use the transform activity. Basically, the transform definition is the same as the assign activity with a slight difference. In the following code, note the <bpelx:annotation>
element, which gives the activity the transform look in JDeveloper:
<assign name = "Transform1" xml:id = "id_29"> <bpelx:annotation xml:id = "id_30"> <bpelx:pattern patternName = "bpelx:transformation" xml:id = "id_31"/> </bpelx:annotation> </assign>
At runtime, when the BPEL engine encounters the Transform
activity, it runs the built-in XSLT engine in order to execute the activity.
Oracle SOA Suite provides several functions for utilizing the XSLT engine as follows:
bpel:doXslTransform()
: This function from the BPEL Extensions section is used for an XSLT transformation with multiple sourcesora:doXSLTransform()
: This is the same function as bpel:doXslTransform()
with a slight difference; it is defined in the BPEL XPath Extension functions sectionora:doXSLTransformForDoc()
: This function is used for an XSLT transformation where the XSLT template matches the document we want to transformora:processXSLT()
: This function returns the result of the XSLT transformationxdk:processXSLT()
: This function is same as ora:processXSLT()
; however, it is used for backward compatibility since it uses the Oracle XDK XSLT processor