Performing Additional Activities Click OK.

Invoking an Asynchronous Web Service from a BPEL Process 8-7 plnk:portType name=client:LoanService plnk:role plnk:role name=LoanServiceRequester plnk:portType name=client:LoanServiceCallback plnk:role plnk:partnerLinkType Two port types are combined into this single asynchronous BPEL process service component: portType=services:LoanService of the invoke activity and portType=services:LoanServiceCallback of the receive activity. Port types are essentially a collection of operations to be performed. For this BPEL process service component, there are two operations to perform: initiate in the invoke activity and onResult in the receive activity.

8.2.2.3 Partner Links Section in the BPEL File

To call the service from BPEL, you use the BPEL file to define how the process interfaces with the web service. View the partnerLinks section. The services with which a process interacts are designed as partner links. Each partner link is characterized by a partnerLinkType. Each partner link is named. This name is used for all service interactions through that partner link. This is critical in correlating responses to different partner links for simultaneous requests of the same type. Asynchronous processes use a second partner link for the callback to the client. In this example, the second partner link, LoanService, is used by the loan application approver web service. Example 8–3 provides an example. Example 8–3 partnerLink Definition -- This process invokes the asynchronous LoanService. -- partnerLink name=LoanService partnerLinkType=services:LoanService myRole=LoanServiceRequester partnerRole=LoanServiceProvider partnerLinks The attribute myRole indicates the role of the client. The attribute partnerRole role indicates the role of the partner in this conversation. Each partnerLinkType has a myRole and partnerRole attribute in asynchronous processes.

8.2.2.4 Composite Application File

In the composite.xml file, the loan application approver web service appears, as shown in Example 8–4 . Example 8–4 Loan Application Approver Web Service component name=LoanBroker implementation.bpel process=LoanBroker.bpel component For more information, see Section 8.2.1.1, Adding a Partner Link for an Asynchronous Service for instructions on creating a partner link. 8-8 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite

8.2.2.5 Invoke and Receive Activities

View the variables and sequence sections. Two areas of particular interest concern the invoke and receive activities: ■ An invoke activity invokes a synchronous web service as discussed in Chapter 7, Invoking a Synchronous Web Service from a BPEL Process or initiates an asynchronous service. The invoke activity includes the request global input variable defined in the variables section. The request global input variable is used by the loan application approver web service. This variable contains the contents of the initial loan application request document. ■ A receive activity that waits for the asynchronous callback from the loan application approver web service. The receive activity includes the response global output variable defined in the variables section. This variable contains the loan offer response. The receive activity asynchronously waits for a callback message from a service. While the BPEL process service component is waiting, it is dehydrated, or compressed and stored, until the callback message arrives. Example 8–5 provides an example. Example 8–5 Invoke and Receive Activities variables variable name=request messageType=services:LoanServiceRequestMessage variable name=response messageType=services:LoanServiceResultMessage variables sequence -- initialize the input of LoanService -- assign -- initiate the remote process -- invoke name=invoke partnerLink=LoanService portType=services:LoanService operation=initiate inputVariable=request -- receive the result of the remote process -- receive name=receive_invoke partnerLink=LoanService portType=services:LoanServiceCallback operation=onResult variable=response When an asynchronous service is initiated with the invoke activity, a correlation ID unique to the client request is also sent, using Web Services Addressing WS-Addressing described in Section 8.4, Using WS-Addressing in an Asynchronous Service . Because multiple processes may be waiting for service callbacks, the server must know which BPEL process service component instance is waiting for a callback message from the loan application approver web service. The correlation ID enables the server to correlate the response with the appropriate requesting instance.

8.2.2.6 createInstance Attribute for Starting a New Instance

You may notice a createInstance attribute in the initial receive activity. In this initial receive activity, the createInstance element is set to yes. This starts a new