What Happens When You Create an Extension

7 Invoking a Synchronous Web Service from a BPEL Process 7-1 7 Invoking a Synchronous Web Service from a BPEL Process This chapter describes how to invoke a synchronous web service from a BPEL process. This chapter demonstrates how to set up the components necessary to perform a synchronous invocation. This chapter also examines how these components are coded. This chapter includes the following sections: ■ Section 7.1, Introduction to Invoking a Synchronous Web Service ■ Section 7.2, Invoking a Synchronous Web Service ■ Section 7.3, Specifying Timeout Values ■ Section 7.4, Calling a One-Way Mediator with a Synchronous BPEL Process For a simple Hello World sample bpel-101-HelloWorld that takes an input string, adds a prefix of Hello to the string, and returns it, visit the following URL: https:soasamples.samplecode.oracle.com

7.1 Introduction to Invoking a Synchronous Web Service

Synchronous web services provide an immediate response to an invocation. BPEL can connect to synchronous web services through a partner link, send data, and then receive the reply in the same synchronous invocation. A synchronous invocation requires the following components: ■ Partner link Defines the location and the role of the web services with which the BPEL process service component connects to perform tasks, and the variables used to carry information between the web service and the BPEL process service component. A partner link is required for each web service that the BPEL process service component calls. You can create partner links in several ways, including the following: – In the SOA Composite Editor, when you drag a Web Service from the Service Adapters section of the Component Palette into the Exposed Services or External References swimlane. For more information, see Section 2.3, Adding Service Binding Components or Section 2.4, Adding Reference Binding Components. – In the Oracle BPEL Designer, when you drag a Partner Link from the BPEL Constructs section of the Component Palette into the Partner Links swimlane. This method is described in this chapter. 7-2 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite ■ Invoke activity Opens a port in the BPEL process service component to send and receive data. For example, this port is used to retrieve information verifying that a customer has acceptable credit using a credit card authorization service. For synchronous callbacks, only one port is needed for both the send and receive functions.

7.2 Invoking a Synchronous Web Service

This section examines a synchronous invocation operation using the OrderProcessor.bpel file in the WebLogic Fusion Order Demo application as an example.

7.2.1 How to Invoke a Synchronous Web Service

To invoke a synchronous web service: 1. In the Component Palette in Oracle BPEL Designer, expand BPEL Constructs. 2. Drag the necessary partner link, invoke activity, scope activity, and assign activity into the designer. 3. Edit their dialogs. Figure 7–1 shows the diagram for the Scope_AuthorizeCreditCard scope activity of the OrderProcessor.bpel file in the Fusion Order Demo, which defines a simple set of actions. Figure 7–1 Diagram of OrderProcessor.bpel The following actions take place:

1. The Assign_CreditCheckInput assign activity packages the data from the client.

The assign activity provides a method for copying the contents of one variable to another. In this case, it takes the credit card type, credit card number, and purchase amount and assigns them to the input variable for the CreditAuthorizationService service.

2. The InvokeCheckCreditCard activity calls the CreditCardAuthorization service.

Figure 7–2 shows the CreditCardAuthorizationService web service, which is defined as a partner link. Invoking a Synchronous Web Service from a BPEL Process 7-3 Figure 7–2 CreditCardAuthorizationService Partner Link Figure 7–3 shows the InvokeCheckCreditCard invoke activity. Figure 7–3 InvokeCheckCreditCard Invoke Activity

3. The Switch_EvaluateCCResult switch activity in

Figure 7–1 checks the results of the credit card validation. For information about switch activities, see Section 10.2.1, Defining Conditional Branching with the Switch Activity in BPEL 1.1. Note: The switch activity is replaced by the if activity in BPEL 2.0.