Using the XSLT transformation in BPEL

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.

Getting ready

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:

  • The first one assigns the request data to the input variable of the web service
  • The second one assigns the response from the web service to the response of the BPEL process

How to do it…

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:

How to do it…

We have just created a transformation activity in the BPEL process.

How it works…

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.

There's more…

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 sources
  • ora:doXSLTransform(): This is the same function as bpel:doXslTransform() with a slight difference; it is defined in the BPEL XPath Extension functions section
  • ora:doXSLTransformForDoc(): This function is used for an XSLT transformation where the XSLT template matches the document we want to transform
  • ora:processXSLT(): This function returns the result of the XSLT transformation
  • xdk:processXSLT(): This function is same as ora:processXSLT(); however, it is used for backward compatibility since it uses the Oracle XDK XSLT processor

See also

  • If we try to deploy the BPEL process that we created, there will be errors reported. The reason for the errors is that the Transform activity has not been configured. In the next recipe, we will configure the Transform activity and make the BPEL process deployable again.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset