Monday, February 11, 2013

Last day / date of a Month

How to get last day / date of a month using XSL

Below are the steps used for achieving it. I have used Xsl variables so that it becomes easier to understand.

  • Create a month and year variable.
  • Add Choose xsl node where we will have one when condition (to check whether month is Feb and year is leap year or not) and in otherwise we will simply get the date. Below is the Xsl source code -

                Thats it. You can test the same in Jdev itself and verify. 

Friday, February 8, 2013

Send XML file as attachment using Email activity in SOA / BPEL 11g

Few days back I got requirement of sending email with attachments. 

The catchy part of it is sending an XML file as attachment. Thought of sharing the solution.

Steps are:
(Version of J-Dev used is

1. Create a BPEL project. 
2. Modify input schema element 'process' to have 'To' and 'AttachmentBody' as string type elements. 
3. Insert a Email Activity inside BPEL.
4. Double Click on the Email activity and set / pass values to required fields. 

5. Create a Temp variable say 'EncodedTemp' and copy 'AttachmentBody' to the EncodedTemp' using assign activity.

6. Insert a JavaEmbedding Activity which will encode the contents of 'EncodedTemp' to Base64Encoding. Below is the code which is used - 

          To use Java Embedding you also need to import oracle.soa.common.util inside BPEL.
          Go to BPEL Source and paste import statements above Java Embedding activity -

7. Now Double click on Email activity again and click on Attachments. Set the values as shown below - 

That is only what you need to do. Deploy the project and test it. It works absolutely fine.. :)