Thursday, July 16, 2009

Converting Synchrous BPEL process to Asynchronous BPEL process

This article is about how to convert a synchronous BPEL process to an asynchronous one.

Whenever we create new bpel process three files are created by default viz.

  • [processName].bpel
  • [processName].wsdl
  • bpel.xml

But the difference between the Synchronous and Asynchronous process remains in the .bpel and .wsdl files only.

If we open the .bpel and .wsdl file of both the processes we do not find much difference in the two therefore it's very easy to convert an asynchronous process to synchronous one and vice-versa.

For explaining how to convert the synchronous process to asynchronous one I have created a BPEL process SynchBP. I’ll be converting SynchBP which is a Synchronous BPEL process to an asynchronous one. As earlier said the difference is only in .bpel and .wsdl file so we'll concentrate only on these two files.

For ease of understanding I have used colours in the text so as to highlight what to change and what to add.

So, first start with SynchBP.bpel file.

There are three places where we have to make changes viz. partnerlink, receive, and reply element.

Partnerlink:

This is how the partnerlink element is of a SynchBP:

<partnerLink name="client" partnerLinkType="client:SynchBP" myRole="SynchBPProvider"/>

Add another attribute partnerRole="SynchBPRequester" to this element. The partnerlink will look like this:

<partnerLink name="client" partnerLinkType="client:SynchBP" myRole="SynchBPProvider" partnerRole="SynchBPRequester"/>

Receive Element:

Below is the receive element of SynchBP

<receive name="receiveInput" partnerLink="client" portType="client:SynchBP" operation="process" variable="inputVariable"
createInstance="yes"/>

Change the value of attribute operation from process to initiate. The partnerlink will look like this:

<receive name="receiveInput" partnerLink="client" portType="client:SynchBP" operation="initiate" variable="inputVariable" createInstance="yes"/>

Reply element:

Below is the reply element of SynchBP

<reply name="replyOutput" partnerLink="client" portType="client:SynchBP" operation="process" variable="outputVariable"/>

Do the following changes to make it for asynchronous process:

  • Change the element name from reply to invoke.
  • Change the name attribute value from replyOutput to callbackClient.
  • Change the value of attribute portType from client:SynchBP to client:SynchBPCallback (or simply [processName]Callback ).
  • Change operation=”process” to operation=”onResult”.
  • Change the name of last attribute i.e. variable to inputvariable.

<invoke name="callbackClient" partnerLink="client" portType="client:SynchBPCallback" operation="onResult" inputVariable="outputVariable"/>

Here we are done with SynchBP.bpel, now we need to edit SynchBP.wsdl.

There are very few changes to be made in the .wsdl file.

The elements that need to be changed are portType and partnerLinkType.

portType:

This is how a portType is defined in a synchronous process:

<portType name="SynchBP">
<operation name="process">
<input message="client:SynchBPRequestMessage" />
<output message="client:SynchBPResponseMessage"/>
</operation>
</portType>

Create another portType element with name SynchronousProcessCallback and operation as onResult. Now delete the output element from both portTypes and in the SynchronousProcessCallback portType, change the attribute value from client:SynchBPRequestMessage to client:SynchBPResponseMessage. (Help: Copy & paste the already defined portType and do as below)

<portType name="SynchBP">
<operation name="initiate">
<input message="client:SynchBPRequestMessage" />
<output message="client:SynchBPResponseMessage"/> ……Remove this
</operation>
</portType>
<portType name="SynchBPCallback">
<operation name="onResult">
<input message="client:SynchBPRequestMessage"/>……. Remove this
<input message="client:SynchBPResponseMessage"/>
</operation>
</portType>

partnerLinkType:

This is how partnerlink information is provided in a wsdl of a synchronous process:

<plnk:partnerLinkType name="SynchBP">
<plnk:role name="SynchBPProvider">
<plnk:portType name="client:SynchBP"/>
</plnk:role>
</plnk:partnerLinkType>

Inside partnerLinkType create one more role element and give it a name as SynchronousProcessRequester. Now inside the role element for portType element change the value of name attribute to client:SynchronousProcessCallback.

<plnk:partnerLinkType name="SynchBP">
<plnk:role name="SynchBPProvider">
<plnk:portType name="client:SynchBP"/>
</plnk:role>
<plnk:role name="SynchBPRequester">
<plnk:portType name="client:SynchBPCallback"/>
</plnk:role>
</plnk:partnerLinkType>

Here we are done with .wsdl file and the SynchBP process is now an asynchronous BPEL Process.

16 comments:

  1. Hi Suryaveer, thank you for your knowlwdge sharing.This is very good.I tried it. And could you also post how to define user defined data types in bpel or i have posted a query in OTN Forum,could you pls tell how. Thank you.

    ReplyDelete
  2. Thanks Satya.
    Can you post the link to your query in oracle forums or plz explain what exactly you mean by user defined data types in bpel.

    ReplyDelete
  3. Hi Suryaveer, user defied data type is structure in c++ or c. I am pasting the schema file here.

    For more clarity in my query, there is a similar requirement in LoanValidator example that come along with insatallation of soa suite.

    The path to LoanValidator is: bpel/samples/utils

    product\10.1.3.1\OracleAS_1\bpel\samples\utils\LoanValidatorService.

    In this project, there is LoanApplicationType which consists of group of elements. And this element is used in InvalidApplicationType as of its element. In this project, both schema file and .wsdl are in wsdl file. But in current version, .xsd and .wsdl files are different right.

    I am not able to define if .xsd and .wsdl are separate files. I am very new to oracle bpel.Actually i am the one who asked you about the bpel training sometime back in OTN Forum.

    Please tell how to do this. Thank you so much.Pls do let me know if anything more is required. Thank you.

    ReplyDelete
  4. Hi,
    I haven't seen that example but regarding the xsd I can say that either you create an schema file and import that into the wsdl or directly write the schema into the wsdl, it is the same. Regarding user defined data types- we create complex types which are user defined. I hope complex types is what you needed.

    ReplyDelete
  5. Hi Suryaveer, thank you so much for your reply. complex type has to be defined. But im not able to define them. Can i send you the files?

    ReplyDelete
  6. Yes why not? But what is the problem you are facing while declaring the complex types??

    ReplyDelete
  7. Hi Suryaveer,thank you.

    The process is an assynchronous process which checks for creadingRating; if creaditRating is <100, its replys the client with an error message 'Invalid application'.Along with the error message, it should also throw all the inputs namely FName,Lname,email,etc. But these elements shud not be defined again in the error message element;instead i want to make use of the input element which contains all these.
    When i tried, its giving error 'cvc complex type 2.3 element cannot character'. I dont know how it should be defined.

    Its not allowing to paste the schema, wsdl files. If anything is required, please do let me know. Or can i email you all the files?i can clearly explain in mail where its giving error.If i can mail, pls do let me know your id.Thank you very much.

    ReplyDelete
  8. Hi Suryaveer, i mailed you the files.Thank you.

    ReplyDelete
  9. Hi Suryaveer, thank you very much for your help. Thanks a lot.I checked the mail and i ran it.This is exactly what i wanted.Now i understood how to define user datatypes. Thank you very much.

    ReplyDelete
  10. hi
    surya... can you please send me some sample examples on mediator concepts by using scope.

    ReplyDelete
  11. Hi surya,

    Thanks a lot for the explanation..i have a similar requirement in my project where i have to change the an existing syncronous process to asyncronous process..
    I did the code changes as per your blog.(in .wsdl and .bpel files)But the deployment is failing.:-(

    can i mail u the files for reference..??and explain where exactly the error is..??thanks u in advance.

    Mahe

    ReplyDelete
  12. Hi surya,

    Thanks a lot for the explanation,There is a similar requirement in my project where i have to change an existing sync process to async process..I did the changes in .wsdl and .bpel files as you mentioned above.But the process is throwing error on compilation..can i mail u the files..??so that it will be easier to explain where exactly it is failing...thanks in advance..

    Mahe

    ReplyDelete

 
Protected by Copyscape DMCA Copyright Detector