...
When invoking a service asynchronously, we need to define two roles (myRole
and partnerRole
) for the partner link. In a synchronous interaction only partnerRole
is need to be defined. These roles are defined in partner link type and they map to particular port types. A partner link type binds two port types; port type process offers(myRole
) to a partner and port type partner offers(partnerRole
) to a process. In the above example DILoanService
is invoked asynchronously and DILoanService
has to provide aportType
, which defines the partnerRole
and another portType
which definesmyRole
.
Deploying the Sample
WSO2 BPS provides a sample, which can be deployed and executed to understand the constructs. Follow the instructions below to deploy and trigger the process.
...
Code Block |
---|
|
<invokename="InvokeCustomerInfo" partnerLink="CustomerInfoPL"
operation="getCustomerSSN" portType="ns1:CustomerInfoPortType"
inputVariable="customerInfoInput" outputVariable="customerInfoOutput"/> |
...
How asynchronous interaction works
In LoanServiceLoanProcess.bpel, the following snippet is given.
Code Block |
---|
|
<invokename="Invoke" partnerLink="DILoanServicePL" operation="getLoanOffer" portType="ns2:LoanServicePortType" inputVariable="diLoanServiceRequest"/><receivename="ReceiveDILoanService" createInstance="no" partnerLink="DILoanServicePL" operation="onLoanOffer" portType="ns2:LoanServiceCallbackPortType" variable="diLoanServiceResponse">
<correlations>
<correlationset="correlator" initiate="no"></correlation>
</correlations>
</receive> |
...
Code Block |
---|
|
<invokename="Invoke" partnerLink="DILoanServicePL" operation="getLoanOffer" portType="ns2:LoanServicePortType" inputVariable="diLoanServiceRequest"/> |
...
Code Block |
---|
|
<partnerLinks>
<partnerLinkname="DILoanServicePL" partnerLinkType="ns2:LoanServicePT" partnerRole="LoanServiceRole" myRole="LoanServiceClientRole"/></partnerLinks> |
...
Code Block |
---|
|
<plnk:partnerLinkTypename="LoanServicePT">
<plnk:rolename="LoanServiceRole" portType="tns:LoanServicePortType"/>
<plnk:rolename="LoanServiceClientRole" portType="tns:LoanServiceCallbackPortType"/>
</plnk:partnerLinkType> |
...
Code Block |
---|
|
<portTypename="LoanServicePortType"><operationname="getLoanOffer"><inputname="input" message="tns:getLoanOfferRequest"/></operation></portType><portTypename="LoanServiceCallbackPortType"><operationname="onLoanOffer"><inputname="input" message="tns:getLoanOfferResponse"/></operation></portType> |
...
Code Block |
---|
|
<receivename="ReceiveDILoanService" createInstance="no" partnerLink="DILoanServicePL" operation="onLoanOffer" portType="ns2:LoanServiceCallbackPortType" variable="diLoanServiceResponse"><correlations><correlationset="correlator" initiate="no"></correlation></correlations></receive> |
...
5. partnerLink="DILoanServicePL"
- An essential attribute in a <receive /> element. This determines the WSDL's portType to be chosen based on the partnerLinkType attribute and the myRole attributes defined in the particular <partnerLink /> element. For example, in LoanServiceLoanProcess.bpel,
Code Block |
---|
|
<partnerLinks><partnerLinkname="DILoanServicePL" partnerLinkType="ns2:LoanServicePT" partnerRole="LoanServiceRole" myRole="LoanServiceClientRole"/></partnerLinks> ......... <receivename="ReceiveDILoanService" createInstance="no" partnerLink="DILoanServicePL" operation="onLoanOffer" portType="ns2:LoanServiceCallbackPortType" variable="diLoanServiceResponse"><correlations><correlationset="correlator" initiate="no"></correlation></correlations></receive> |
...
Code Block |
---|
|
<bpws:propertyAliaspropertyName="tns:correlatorProp" messageType="ns1:getLoanOfferResponse" part="part"><bpws:query>/ns:CustomerInfo/ns:CustomerID</bpws:query></bpws:propertyAlias> |
...