Calling a One-Way Mediator with a Synchronous BPEL Process

8 Invoking an Asynchronous Web Service from a BPEL Process 8-1 8 Invoking an Asynchronous Web Service from a BPEL Process This chapter describes how to call an asynchronous web service. Asynchronous messaging styles are useful for environments in which a service, such as a loan processor, can take a long time to process a client request. Asynchronous services also provide a more reliable fault-tolerant and scalable architecture than synchronous services. This chapter includes the following sections: ■ Section 8.1, Introduction to Invoking an Asynchronous Web Service ■ Section 8.2, Invoking an Asynchronous Web Service ■ Section 8.3, Using a Dynamic Partner Link at Runtime ■ Section 8.4, Using WS-Addressing in an Asynchronous Service ■ Section 8.5, Using Correlation Sets in an Asynchronous Service

8.1 Introduction to Invoking an Asynchronous Web Service

This section introduces asynchronous web service invocation with a company called United Loan. United Loan publishes an asynchronous web service that processes a client’s loan application request and then returns a loan offer. This use case discusses how to integrate a BPEL process service component with this asynchronous loan application approver web service. This use case illustrates the key design concepts for requesting information from an asynchronous service, and then receiving the response. The asynchronous United Loan service in this example is another BPEL process service component. However, the same BPEL call can interact with any properly designed web service. The target web service WSDL file contains the information necessary to request and receive the necessary information. For the asynchronous web service, the following actions take place in order of priority: 1. An assign activity prepares the loan application. 2. An invoke activity initiates the loan request. The contents of this request are put into a request variable. This request variable is sent to the asynchronous loan processor web service. When the loan request is initiated, a correlation ID unique to the client and partner link initiating the request is also sent to the loan processor web service. The 8-2 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite correlation ID ensures that the correct loan offer response is returned to the corresponding loan application requester. 3. The loan processor web service then sends the correct response to the receive activity, which has been tracked by the correlation ID. 4. An assign activity reads the loan application offer. The remaining sections in this chapter provide specific details about the asynchronous functionality.

8.2 Invoking an Asynchronous Web Service

This section provides an overview of the tasks for adding asynchronous functionality to a BPEL process service component.

8.2.1 How to Invoke an Asynchronous Web Service

You perform the following steps to asynchronously invoke a web service: ■ Add a partner link ■ Add an invoke activity ■ Add a receive activity ■ Create assign activities

8.2.1.1 Adding a Partner Link for an Asynchronous Service

These instructions describe how to create a partner link in a BPEL process for this example, named LoanService for the loan application approver web service. To add a partner link for an asynchronous service: 1. In the SOA Composite Editor, drag a BPEL process from the Service Components section of the Component Palette into the designer. The Create BPEL Process dialog appears. 2. Follow the instructions in the dialog to create a BPEL process service component.

3. Click OK when complete.

4. In the SOA composite application in the SOA Composite Editor, double-click the BPEL process service component for this example, the component is named LoanBroker . The Oracle BPEL Designer appears.

5. In the Component Palette, expand BPEL Constructs.

6. Drag a Partner Link icon into the right Partner Links swimlane.

The Create Partner Link dialog appears. 7. Enter the following details to create a partner link and select the loan application approver web service: ■ Name Enter a name for the partner link for this example, LoanService is entered. ■ Process Invoking an Asynchronous Web Service from a BPEL Process 8-3 Displays the BPEL process service component name for this example, LoanBroker appears. ■ WSDL URL Enter the name of the Web Services Description Language WSDL file to use. Click the SOA Resource Lookup icon above this field to locate the correct WSDL. ■ Partner Link Type Refers to the external service with which the BPEL process service component is to interface. Select from the list for this example, LoanService is selected. ■ Partner Role Refers to the role of the external source, for example, provider. Select from the list for this example, LoanServiceProvider is selected. ■ My Role Refers to the role of the BPEL process service component in this interaction. Select from the list for this example, LoanServiceRequester is selected.

8. Click OK.

A new partner link for the loan application approver web service United Loan appears in the swimlane of the designer.

8.2.1.2 Adding an Invoke Activity

Follow these instructions to create an invoke activity and a global input variable named request. This activity initiates the asynchronous BPEL process service component activity with the loan application approver web service United Loan. The loan application approver web service uses the request input variable to receive the loan request from the client. To add an invoke activity: 1. In the Component Palette, expand BPEL Constructs. 2. Drag an Invoke activity to beneath the Receive activity. 3. Go to the Structure window. Note that while this example describes variable creation from the Structure window, you can also create variables by clicking the Add icons to the right of the Input and Output fields of the Invoke dialog.

4. Right-click Variables and select Expand All Child Nodes.

5. In the second Variables folder in the tree, right-click and select Create Variable.

The Create Variable dialog appears.

6. Enter the variable name and select Message Type from the options provided:

■ Type This option lets you select an XML schema simple type for example, string, boolean, and so on. ■ Message Type This option enables you to select a WSDL message file definition of a partner link or of the project WSDL file of the current BPEL process service component for example, a response message or a request message. You can specify