Gopalan Suresh Raj's Web Cornucopia
An Oasis for the parched Enterprise Services Engineer/Developer

    WS-BPEL-What are partnerLinkTypes, roles, and partnerLinks

    WS-BPEL

    WS-BPEL is a Web Service Sequencing Language. A BPEL Process defines a conversation flow chart and a BPEL Process instance is a particular conversation following the chart which consists of only WSDL-described message exchanges. BPEL provides and consumes WSDL-defined services. BPEL execution systems can thus support multiple concurrent conversations.

    Links to all the different WSDL-defined web services that a BPEL process instance interacts with are called partner links. They are concrete references to services that a BPEL business process interacts with. Links to WSDL-defined web services that are invoked by a BPEL process are called Invoked partner links. Similarly, links to WSDL-defined web services that can invoke a BPEL process are called Client partner links. Each BPEL process will definitely have at least one Client partner link since a BPEL process can only be instantiated with a call from a Client partner.

    A BPEL process can interact with a WSDL-defined web service in three distinct ways:

    1. WSDL-defined web services can invoke a BPEL process
    2. WSDL-defined web services can be invoked by a BPEL process
    3. WSDL-defined web services that have either characteristics or roles, in that, they may be invoked by the BPEL process, and they may in turn invoke the BPEL process.

    Scenario 1: WSDL-defined web services can invoke a BPEL process

    In this scenario, the BPEL process provides a IRequestLoan portType (interface) through which a WSDL-defined Client Partner web service invokes the requestLoan operation.

    From the WSDL-service Client Partner’s point of view, it requires a BPEL Process to provide a IRequestLoan portType(interface) with a requestLoan operation that it can invoke. From the BPEL Process’s point of view, it offers a IRequestLoan portType(interface) with a requestLoan operation that any other web service could invoke.

    Partner Link Type and Role:

    Instead of describing business processes based on a certain point of view, BPEL introduces the concept of a role, and the concept of a partner link type. Relationships are modeled based on the role that they play in the business process rather than individual points of view. A partner link type defines how two individual WSDL-defined partners can interact together and what each of the partners have to offer. __partner link type__s are defined in WSDL files through the WSDL extensibility element mechanism.

    Scenario 2: WSDL-defined web services can be invoked by a BPEL process

    In this scenario, the Invoked partner provides a ILoanProcessor portType (interface) through which a WSDL-defined BPEL Process invokes the processLoanRequest operation.

    From the BPEL Process’s point of view, it requires a WSDL-defined Invoked Partner to provide a LoanProcessor portType with a processLoanRequest operation that it can invoke. From the Invoked Partner’s point of view, it offers a LoanProcessor portType with a processLoanRequest operation that any other web service could invoke.

    Scenario 3: WSDL-defined web services that have either characteristics

    In this scenario, a WSDL-defined Invoked Partner offers a IAdjuster portType (interface) that has an addNewAdjustmentJob operation. the BPEL process provides a AdjusterCallback portType (interface) that the Invoked Partner can use to callback the BPEL Process’s submitAdjustmentJob operation.

    From the BPEL Process’s point of view, the process requires a WSDL-defined Invoked Partner that implements the IAdjuster portType (interface) with a addNewAdjustmentJob operation and provides an AdjusterCallback portType (interface) with a submitAdjustmentJob operation. From the WSDL-defined Invoked Partner’s point of view, it offers an IAdjuster portType (interface) with a addNewAdjustmentJob operation and requires a BPEL Process that provides an AdjusterCallback portType (interface) with a submitAdjustmentJob operation.

    The partnerLinkType and role Definitions in WSDL Files

    __Partner link type__s are defined in WSDL files through the WSDL extensibility element mechanism. The <partnerLinkType> element is embedded directly within the WSDL file of every partner process and service process involved in a BPEL orchestration. <partnerLinkType> elements defined in the partner’s WSDL file identify the WSDL portType (interface) element referenced by the partnerLink in the service process’s BPEL process definition.

    The <partnerLinkType> element contains one <role> element for each role (service provider or service consumer) the service process can play, as defined by its partnerLink element—myRole (indicating a service provider) and partnerRole (indicating a service consumer) attributes—in the service process’s BPEL process definition. Therefore, a partnerLinkType can have either one or two <role> child elements. The following example shows one <role> child element.

    <definitions name="LoanProcessorEJBWrapper"
                targetNamespace="http://localhost/loanRequestorBpel/LoanProcessorEJBWrapper"
                xmlns:tns="http://localhost/loanRequestorBpel/LoanProcessorEJBWrapper"
                xmlns="http://schemas.xmlsoap.org/wsdl/"
                xmlns:plink="http://schemas.xmlsoap.org/ws/2004/03/partner-link/"
    ...
    >
    ...
      <plink:partnerLinkType name="loanProcessorEjbPartner">
        <plink:role name="loanProcessorEJB" 
                    portType="ns:LoanProcessorEJBSEI">
        </plink:role>
      </plink:partnerLinkType>
    ...
    

    </definitions> In situations when a service process has the same relationship with multiple partner processes, the service process’s BPEL partnerLink elements can reference the same partnerLinkType.

    The partnerLinks and partnerLink Definitions in BPEL files

    __Partner Link__s are defined in BPEL files. The <partnerLink> definition defines the portType (interface) of the partner process that will participate in BPEL orchestrations of the business process being defined. These partner processes can act as clients to the service process being defined or can be invoked by the service process. The <partnerLink> element encodes communication exchange information between the service process and its partner processes. The role of the service process will vary according to the nature of communication with its partner process. For the example, when the LoanRequestor service process invokes a LoanProcessorEJB partner process, it may act in a LoanRequestor role and the LoanProcessorEJB partner process may act in a LoanProcessorEJB role.

    The <partnerLink> element contains the myRole and partnerRole attributes that establish the roles for the service process and its partner process, respectively, as illustrated in the following code example.

    <partnerLinks>
      <partnerLink name="bpelImplemented"
                   partnerLinkType="ns0:loanRequestorPartnerLinkType"
                   myRole="loanRequestor"/>
      <partnerLink name="ejbInvoked"
                   partnerLinkType="ns1:loanProcessorEjbPartner"
                   partnerRole="loanProcessorEJB"/>
    </partnerLinks>
    

    The myRole attribute is used when the service process acts as the service provider and is being invoked by a service consumer partner process client. Similarly, the partnerRole attribute identifies the service provider partner process that the service process is invoking when acting in a service consumer client role.

    The screen-shot below shows the WSDL for Scenarios 1 and 2 The screen-shot below shows the BPEL for Scenarios 1 and 2
    Alt Alt

    Author Bibliography

    Gopalan Suresh Raj is a Senior Analyst, Software Architect, and Developer with expertise in multi-tiered systems development, enterprise service architectures, and distributed computing. He is also an active author, including contributions to Professional JMS Programming, Wrox Press, 2001, Enterprise Java Computing-Applications and Architecture, Cambridge University Press, 1999, and The Awesome Power of JavaBeans, Manning Publications Co., 1998. He has submitted papers at international fora, and his work has been published in numerous technical journals. Visit him at his Web Cornucopia© site (webcornucopia.com) or mail him at gopalan@webcornucopia.com.

    Back