Friday, February 23, 2018

Changing a BPEL process' interface definition from asynchronous to synchronous (and vice versa)


So it happened to me before that during development I came to realize that my BPEL process should have been designed as synchronous in the first place instead of having an asynchronous definition. When you were already well under way developing you're not really keen on throwing your work away and start all over. Well the good news is that you don't have to. It's actually quite easy to transform your BPEL process from an asynchronous into a synchronous interface. It even works the other way around. I'll demonstrate how.

So this is what we're talking about. When you start off you used the asynchronous BPEL process template.


With hindsight, you wanted to use the synchronous BPEL process template.


Now to change the interface definition we will have to make alterations in three files:
 - The composite.xml
 - The .bpel file
 - The WSDL 

1. The composite.xml
Look for the interface.wsdl tag and remove the yellow part. If you need to convert your BPEL from synchronous to asynchronous, add the yellow part.
<interface.wsdl interface="http://xmlns.oracle.com/WCC_Orchestration_BPELapp/SampleProject/SampleProjectBpel#wsdl.interface(SampleProjectBpel)" callbackInterface="http://xmlns.oracle.com/WCC_Orchestration_BPELapp/SampleProject/SampleProjectBpel#wsdl.interface(SampleProjectBpelCallback)"/>

Look for the callback tag and remove the yellow part. If you need to convert your BPEL from synchronous to asynchronous, add the yellow part within the <service></service> tags.
<callback>
<binding.ws port="http://xmlns.oracle.com/WCC_Orchestration_BPELapp/SampleProject/SampleProjectBpel#wsdl.endpoint(sampleprojectbpel_client_ep/SampleProjectBpelCallback_pt)"/>
</callback>

Look for the componentType tag and remove the yellow part. If you need to convert your BPEL from synchronous to asynchronous, add the yellow part.
<componentType>
<service name="sampleprojectbpel_client" ui:wsdlLocation="WSDLs/SampleProjectBpel.wsdl">
<interface.wsdl interface="http://xmlns.oracle.com/WCC_Orchestration_BPELapp/SampleProject/SampleProjectBpel#wsdl.interface(SampleProjectBpel)"
 callbackInterface="http://xmlns.oracle.com/WCC_Orchestration_BPELapp/SampleProject/SampleProjectBpel#wsdl.interface(SampleProjectBpelCallback)"/>
</service>
</componentType>

Look for the following property:
<property name="bpel.config.oneWayDeliveryPolicy" type="xs:string" many="false">async.persist</property>
Change it to:
<property name="bpel.config.transaction" type="xs:string" many="false">required</property>
If you need to convert your BPEL from synchronous to asynchronous, replace the blue with the yellow parts.

2. The .bpel file
Look for the partnerlink tag and remove the yellow part.
If you need to convert your BPEL from synchronous to asynchronous, add the yellow part.
<partnerLink name="sampleprojectbpel_client" partnerLinkType="client:SampleProjectBpel" myRole="SampleProjectBpelProvider" partnerRole="SampleProjectBpelRequester"/>

Look for the invoke construct:
<invoke name="callbackClient" partnerLink="sampleprojectbpel_client" portType="client:SampleProjectBpelCallback" operation="processResponse" inputVariable="outputVariable"/>
Change it to:
<reply name="replyOutput" partnerLink="sampleprojectbpel_client" portType="client:SampleProjectBpel" operation="process" variable="outputVariable"/>
If you need to convert your BPEL from synchronous to asynchronous, replace the blue with the yellow parts.

3. The WSDL 
Look for the portType tag that contains the Callback and remove it.
If you need to convert your BPEL from synchronous to asynchronous, add it.
<wsdl:portType name="SampleProjectBpelCallback">
   <wsdl:operation name="processResponse">
       <wsdl:input message="client:SampleProjectBpelResponseMessage"/>
    </wsdl:operation>
</wsdl:portType> 

Now look for the other portType tag and add the yellow part to set the output message.
If you need to convert your BPEL from synchronous to asynchronous, delete it.
<wsdl:portType name="SampleProjectBpel">
    <wsdl:operation name="process">
       <wsdl:input message="client:SampleProjectBpelRequestMessage"/>
       <wsdl:output message="client:SampleProjectBpelResponseMessage"/>
    </wsdl:operation>
</wsdl:portType>

Look for the partnerLinkType tag and delete the yellow part.
If you need to convert your BPEL from synchronous to asynchronous, add it.
<plnk:partnerLinkType name="SampleProjectBpel">
      <plnk:role name="SampleProjectBpelProvider" portType="client:SampleProjectBpel"/>
      <plnk:role name="SampleProjectBpelRequester" portType="client:SampleProjectBpelCallback"/>
</plnk:partnerLinkType>

That's all!