The InvokeCheckCreditCard activity calls the CreditCardAuthorization service.

7-4 Oracle Fusion Middleware Developers Guide for Oracle SOA Suite

7.2.2 What Happens When You Invoke a Synchronous Web Service

When you create a partner link and invoke activity, the necessary BPEL code for invoking a synchronous web service is added to the appropriate BPEL and Web Services Description Language WSDL files.

7.2.2.1 Partner Link in the BPEL Code

In the OrderProcessor.bpel code, the partner link defines the link name and type, and the role of the BPEL process service component in interacting with the partner service. From the BPEL source code, the CreditCardAuthorizationService partner link definition is shown in Example 7–1 : Example 7–1 Partner Link Definition partnerLink name=CreditCardAuthorizationService partnerRole=CreditAuthorizationPort partnerLinkType=ns2:CreditCardAuthorizationService Variable definitions that are accessible locally in the Scope_AuthorizeCreditCard scope are shown in Example 7–2 . The types for these variables are defined in the WSDL for the process itself. Example 7–2 Variable Definition variable name=lCreditCardInput messageType=ns2:CreditAuthorizationRequestMessage variable name=lCreditCardOutput messageType=ns2:CreditAuthorizationResponseMessage The WSDL file defines the interface to your BPEL process service component: the messages that it accepts and returns, the operations that are supported, and other parameters.

7.2.2.2 Partner Link Type and Port Type in the BPEL Code

The web service’s CreditCardAuthorizationService.wsdl file contains two sections that enable the web service to work with BPEL process service components: ■ partnerLinkType: Defines the following characteristics of the conversion between a BPEL process service component and the credit card authorization web service: – The role operation played by each – The portType provided by each for receiving messages within the conversation ■ portType: A collection of related operations implemented by a participant in a conversation. A port type defines which information is passed back and forth, the form of that information, and so on. A synchronous invocation requires only one port type that both initiates the synchronous process and calls back the client with the response. An asynchronous callback one in which the reply is not immediate requires two port types, one to send the request, and another to receive the reply when it arrives. Invoking a Synchronous Web Service from a BPEL Process 7-5 In this example, the portType CreditAuthorizationPort receives the credit card type, credit card number, and purchase amount, and returns the status results. Example 7–3 provides an example of partnerLinkType and portType. Example 7–3 partnerLinkType and portType Definitions plnk:partnerLinkType name=CreditCardAuthorizationService plnk:role name=CreditAuthorizationPort plnk:portType name=tns:CreditAuthorizationPort plnk:role plnk:partnerLinkType

7.2.2.3 Invoke Activity for Performing a Request

The invoke activity includes the lCreditCardInput local input variable. The credit card authorization web service uses the lCreditCardInput input variable. This variable contains the customer’s credit card type, credit card number, and purchase amount. The lCreditCardOutput variable returns status results from the CreditAuthorizationService service. Example 7–4 provides an example. Example 7–4 Invoke Activity invoke name=InvokeCheckCreditCard inputVariable=lCreditCardInput outputVariable=lCreditCardOutput partnerLink=CreditCardAuthorizationService portType=ns2:CreditAuthorizationPort operation=AuthorizeCredit

7.2.2.4 Synchronous Invocation in BPEL Code

The BPEL code shown in Example 7–5 performs the synchronous invocation: Example 7–5 Synchronous Invocation assign name=Assign_CreditCheckInput copy from variable=gOrderInfoVariable query=ns4:orderInfoVOSDOns4:OrderTotal to variable=lCreditCardInput part=Authorization query=ns8:AuthInformationns8:PurchaseAmount copy copy from variable=gOrderInfoVariable query=ns4:orderInfoVOSDOns4:CardTypeCode to variable=lCreditCardInput part=Authorization query=ns8:AuthInformationns8:CCType copy copy from variable=gOrderInfoVariable query=ns4:orderInfoVOSDOns4:AccountNumber to variable=lCreditCardInput part=Authorization query=ns8:AuthInformationns8:CCNumber copy assign invoke name=InvokeCheckCreditCard inputVariable=lCreditCardInput outputVariable=lCreditCardOutput partnerLink=CreditCardAuthorizationService