eXTReMe Tracker

Thursday, September 11, 2008

Multiple operations in a BPEL process

Creating multiple operations inside a single portType in a BPEL process:

1) Prepare a WSDL with two operations(OP1 and OP2) in a portType ( they can have the same/different request and response messages)
2) Open JDeveloper
3) Create an empty BPEL process
4) Create a partner link with the WSDL created above and name it as 'client'
5) Add a 'Pick' activity and delete the 'OnAlarm' activity
6) Double click 'Pick' activity and select 'Create Instance'
OnMessage1:
7) Double click 'OnMessage' activity and select 'client' with OP1
8) Add an 'Assign' activity to set the output variable to 'OP1' and use that in reply to 'client' OP1
OnMessage2:
8) Add another 'OnMessage' activity and set it to OP2 of 'client'.
9) Add an 'Assign' activity to set the output variable to 'OP2' and use that in reply to 'client' OP2
10)Deploy the process
11)Start soapUI and invoke 'OP1' operation to get 'OP1' as the response and vice-versa.

Note: Oracle BPEL PM Console does not support multiple operations yet. It invokes only one operation irrespective of the operation selected, as of 10.1.3.3.1.
Not knowing this fact, I got stuck with the BPEL Console for a day and then I tried in soapUI and figured out that there is a bug in the BPEL console jsp.


Validating input XML and sending out email for invalid XML in BPEL

I had this requirement recently to validate the input XML document before proeeding with the process orchestration.
We can keep the logic to validate the XML at the application tier, which is the client calling the BPEL process or
we can keep the logic on the database tier, which is nothing but the partner link to which my process connects (PL/SQL package for example).
The earlier approach reduces the reusability of the process any client which does not have a validation logic
needs to change its code to do the pre-invoke validations. And the later approach introduces an overhead on the
database tier as validating the XML documents on database tier would require the registration of schema and also the
validation on this side is pretty expensive.

So, the better approach is to validate in the BPEL layer.
You can do this by setting the 'validateXML' property to 'true' at the domain level. But this approach has a
disadvantage that it would apply it for all the processes on the domain and for all the partner links inside a process.
What if one needs to validate only the inbound XML.
Here's how:
1) Double click on 'client' partner link
2) Go to Property tab
3) Create a new property named 'validateXML' and set its value to true

Now, your BPEL process will validate all the XML documents related to 'client'.
What if you wanted to notify someone incase of invalid XML documents?
Here's how:
1) Declare a fault message shown below and then declare a fault variable of this message type:
<message name="InvalidXML_Message">
        <part name="code" type="xsd:string"/>
        <part name="summary" type="xsd:string"/>
        <part name="detail" type="xsd:string"/>
2) Add a Catch activity and fill the following information:
Namespace URI:http://schemas.oracle.com/bpel/extension
LocalPart:invalidVariables
Faultvariable: Mention the variable defined above
3) Add an email activity and copy the above variable to content body

You are all set to catch the invalid XML documents and notify your support team..!!!

Monday, September 8, 2008

Formatting email content - BPEL Email activity

I had this requirement in BPEL to email a certain group incase of any errors in a BPEL process.We could achieve this
using a simple Email activity in BPEL. But, my client wanted me to send the notification in a formatted way, such as:

The following error has occurred in XX process:
------------------------------------------------
Error Code:XX
Error Message:XXXX
------------------------------------------------
Please check the following instance for more information:
http:\\link_for_the_instance
------------------------------------------------

The problem with the above format is that is has new line characters in between. I came across somewhere that we can insert new line using "& # 13 ; "(no spaces). It's the character to insert newline in XML payload. But it never worked.

Then I found from Dharmendra Dubey's blog that JDeveloper changes "
& # 13 ;" to "amp # 13 ; "(no spaces). So I went to the source view and edited 'amp' back to '& '. But still, I wasn't able to get the new line character in my payload.

Then I figured out that we need to change the MimeType from 'text/html' to 'text/plain' to make this whole damn thing work.

Furthermore, I wanted the link for the instance to be dynamic. So, I have used getdomainId(),getProcessId(),getProcessVersion() and getinstanceId() functions to prepare the link and concatenated it to my content body.

Voila..Your email with formatted body is ready..but it is in plain text and what that means is that you can't have colors and etc..

Now, lets look at the other option which is 'html'. You can write simple HTML code to groom the message
as nicer as you want and use that in 'Email' acitivity of the BPEL.
For example, here's a simple piece of HTML code to insert a newline and also to play with the font sizes and colors:

<FONT SIZE=4
>
Here is the message:<br>

</FONT>
<FONT SIZE=2 >
<B>
Message Text Here
<HR ALIGN=LEFT>
</FONT>

Just copy and paste the above code in the content portion of your 'Email' actitivity and modify it as you wish to send a notification
with different fonts, colors and what not.




JDeveloper - Scrolling problem

I recently bought a new laptop which obviously came with Windows Vista (64bit).
I was facing a strange(but not new) problem with it when I scroll down in a source view or in design view, it mixes up the text in the screen and it becomes really annoying to make the JDeveloper repaint the text. It takes lot of 'Ctlr+A's and clicks to repaint the whole thing.

I've read many blogs and people suggested many things such as upgrading to JDK 6 and so on and so forth. But nothing worked.

So, here is a work around for the problem:
1)Right click jdeveloper.exe and go to compatibility tab
2)Check 'Run in 256 colours'
3)Open the Jdeveloper now.

Scrolling problem won't be there now. But all the other applications on your desktop will change their colors.These colors wil be restored automatically when you close the JDeveloper.

So, this might not be the perfect solution, but surely is a workaround.
Another small workaround is using the scroll bar instead of the mouse wheel to scroll thru the code.

I have raised an SR with Oracle and shall update here when I get a resolution(hopefully!)...