Book Image

BPEL and Java Cookbook

By : Jurij Laznik
Book Image

BPEL and Java Cookbook

By: Jurij Laznik

Overview of this book

The Business Process Execution Language (BPEL) has become the de-facto standard for orchestrating web services. BPEL and web services are both clamped into Service-oriented Architecture (SOA). Development of efficient SOA composites too often requires usage of other technologies or languages, like Java. This Cookbook explains through the use of examples how to efficiently integrate BPEL with custom Java functionality.If you need to use BPEL programming to develop web services in SOA development, this book is for you.BPEL and Java Cookbook will show you how to efficiently integrate custom Java functionality into BPEL processes. Based on practical examples, this book shows you the solutions to a number of issues developers come across when designing SOA composite applications. The integration between the two technologies is shown two-fold; the book focuses on the ways that Java utilizes the BPEL and vice-versa.With this book, you will take a journey through a number of recipes that solve particular problems with developing SOA composite applications. Each chapter works on a different set of recipes in a specific area. The recipes cover the whole lifecycle of developing SOA composites: from specification, through design, testing and deployment. BPEL and Java Cookbook starts off with recipes that cover initiation of BPEL from Java and vice-versa. It then moves on to logging and tracing facilities, validation and transformation of BPEL servers, embedding of third-party Java libraries into BPEL. It also covers manipulation with variables in BPEL different techniques of Java code wrapping for web service usage and utilization of XML fa?ßades. After reading BPEL and Java Cookbook you will be able to circumvent many of the issues that developers experience during SOA composite application development.  
Table of Contents (18 chapters)
BPEL and Java Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Gathering a BPEL process's in and out parameters


This recipe will explain the ways of getting input and output parameters about a BPEL process. The information gathered is very important if we want to call the BPEL process from Java applications.

How to do it…

We are deploying the BPEL process on the BPEL server. The business process is now ready to be executed; however, we don't have any information about the business process besides the WSDL location of the business process.

  1. In the Oracle Enterprise Manager Console, we select the BPEL process from the tree, and click on the following icon:

  2. We receive information about the business process endpoint URI and a location of the business process WSDL as shown in the following screenshot:

  3. By entering the WSDL address into the web browser, we receive a description of the BPEL process interface. In this definition, we check for the input and output messages as follows:

    <wsdl: message name = "HelloWorldProcessRequestMessage">
      <wsdl: part name = "payload" element = "client:process"/>
    </wsdl: message>
    <wsdl: message name = "HelloWorldProcessResponseMessage">
      <wsdl: part name = "payload" element = "client: processResponse"/>
    </wsdl: message>
    <wsdl: portType name = "HelloWorldProcess">
      <wsdl: operation name = "process">
      <wsdl: input message = "client: HelloWorldProcessRequestMessage"/>
      <wsdl: output message = "client:HelloWorldProcessResponseMessage"/>
      </wsdl:operation>
    </wsdl:portType>
  4. The most interesting part of WSDL is the <wsdl:operation> element, which indicates the entry point, the functionality, and the input and output messages of the BPEL process. We see that the input and output parameters both have a defined message in the client namespace, which is defined as the XSD schema. We can find its location in WSDL under the <import> tag. We search for the client: process input parameter in the XSD schema:

    <element name="process">
      <complexType>
        <sequence>
          <element name="input" type="string"/>
        </sequence>
      </complexType>
    </element>
  5. As we can see, the input parameter takes the string variable with the name input. Similarly, we explore the output parameter client: processResponse in the XSD schema as follows:

    <element name="processResponse">
      <complexType>
        <sequence>
          <element name="result" type="string"/>
        </sequence>
      </complexType>
    </element>
  6. The BPEL process will return the string variable named result.

How it works…

In general, there are two approaches to designing the BPEL processes. The first one is the top-down approach, where we first develop the XSD schema and WSDL files, which is also called the contract-first approach . The next one is called the bottom-up approach, where we start from the already-written Java code and generate the XSD schema and WSDL files with tools.

The recommended approach when designing the BPEL processes is to first define the XSD schema, which contains the definition of the input and output parameters. This is also the proper place to put the various complex variables used in the business process.

The schema is later used by WSDL to define the BPEL process interface via the <wsdl: portType> element. Both WSDL and the XSD schema are packed into the deployment package and deployed to the BPEL server.

Note

The definition of the input and output parameters in the XSD schema is not mandatory. We can easily define them in WSDL of the BPEL process. However, we lose some of the readability of the WSDL document. Note that such an approach is bad practice and is not recommended, since it hinders the reusability of the XML data types and elements.

See also

  • To learn about the deployment of a BPEL process, refer to the previous recipe, Deploying a BPEL process