Chapter 5. Transforming and Validating the BPEL Services

This chapter contains the following recipes:

  • Using the XSLT transformation in BPEL
  • Generating the XSLT map with the XSLT mapper
  • Performing copy between the variables
  • Using the functions in the transformation operations
  • The chaining functions
  • Defining and importing the user-defined functions
  • Using the xsl:for-each command
  • Defining a parameter
  • Defining a variable
  • Validating the variables with the <assign> activity

Introduction

In the SOA architecture, BPEL plays the role of the orchestration technology. Its main task is to efficiently coordinate the interaction between web services in the business processes. With the vendor extensions, it is also possible to orchestrate EJB, Java, Spring, REST, and the other compositions.

The design of the BPEL processes requires the orchestration of many web services, each with its own interface and a way of interaction with the outer environment. There will be rare cases when web services along with a business process are in our domain. Web services, in this case, are distinct entities, and so we need to adapt our business process to the interface of the calling web service. In such a scenario, we often encounter the incompatibilities of the web service interfaces. Consequently, the job of BPEL is also the translation of some web service outcome to become the request of another web service. We have already seen that some basic transformations can be done with the assign activity, especially if the from and to variables are of the same kind.

For a more complex mapping, we use the XSLT (Extensible Stylesheet Language Transformations) transformation abilities of Oracle SOA Suite since XSLT presents an XML document describing the transformation. The purpose of XSLT is to perform the transformation from XML document to XML document, HTML pages, plain text, and other formats. Oracle SOA Suite also provides a built-in XSLT engine, and therefore it is easy to utilize XSLT with Oracle.

We create the XSLT transformation with the help of JDeveloper which provides a component named the XSLT mapper, which is opened when we double-click on the Transform activity. The result of the XSLT transformation activity is the <assign> activity in the business process and a transformation file that has the XSLT extension. The XSLT transformation files are stored in the XSLT directory in the JDeveloper project. We can use two views to design the XSLT transformations in JDeveloper. The first one is the visual mapping editor, where we can do most of the job by using drag-and-drop. The other view is the source view, where we change the XSLT code manually.

When we are satisfied with the XSLT transformation file, we can test if the transformation works as expected since JDeveloper also offers the testing facility.

Another important aspect of data manipulation is validation. The business data in a BPEL process is stored in the variables. Data is in the XML format. With validation, we want to ensure that the XML content conforms to the well-defined paradigm and also follows the defined structure of the XML schema. Furthermore, our goal is to catch the invalid XML data as soon as possible. Invalid XML data can cause unpredictable damage to a BPEL process, thus leaving the BPEL process in an unknown state. To repair such a BPEL process, it is often not enough to perform fault handling or compensation, since fault handling and compensation might also use the faulty data to perform its tasks. Rather, manual changes of modifications are needed, which for example include manual SQL insert/update/delete statement execution on the databases.

In this chapter, we will focus on the recipes that provide efficient XSLT transformation as well as validation of the XML data.

..................Content has been hidden....................

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