Attachments in Oracle BPM 11g – Create a BPM Process Instance by passing an Attachment
Posted
by Venugopal Mangipudi
on Oracle Blogs
See other posts from Oracle Blogs
or by Venugopal Mangipudi
Published on Thu, 31 Oct 2013 10:56:03 +0000
Indexed on
2013/10/31
16:07 UTC
Read the original article
Hit count: 382
/Oracle
Problem Statement:
On a recent engagement I had a requirement where we needed to create BPM instances using a message start event. The challenge was that the instance needed to be created after polling a file location and attaching the picked up file (pdf) as an attachment to the instance.
Proposed Solution:
I was contemplating using process API to accomplish this,but came up with a solution which involves a BPEL process to pickup the file and send a notification to the BPM process by passing the attachment as a payload. The following are some of the brief steps that were used to build the solution:
- BPM Process to receive an attachment as part of the payload:
The BPM Process is a very simple process which has a Message Start event that accepts the attachment as an argument and a Simple User Task that the user can use to view the attachment (as part of the OOTB attachment panel).
The Input payload is based on AttachmentPayload.xsd. The 3 key elements of the the payload are:
<xsd:element name="filename" type="xsd:string"/>
<xsd:element name="mimetype" type="xsd:string"/>
<xsd:element name="content" type="xsd:base64Binary"/>
A screenshot of the Human task data assignment that need to performed to attach the file is provided here. Once the process and the UI project (default generated UI) are deployed to the SOA server, copy the wsdl location of the process service (from EM). This WSDL would be used in the BPEL project to create the Instances in the BPM process after a file is polled.
- BPEL Process to Poll for File and create instances in the BPM process:
For the BPEL process a File adapter was configured as a Read service (File Streaming option and keeping the Schema as Opaque). Once a location and the file pattern to poll are provided the Readservice Partner Link was wired to Invoke the BPEL Process. Also, using the BPM Process WSDL, we can create the Webservice reference and can invoke the start operation. Before we do the assignment for the Invoke operation, a global variable should be created to hold the value of the fileName of the file. The mapping to the global variable can be done on the Receive activity properties (jca.file.FileName).
So for the assign operation before we invoke the BPM process service, we can get the content of the file from the receive input variable and the fileName from the jca.file.FileName property. The mimetype needs to be hard coded to the mime-type of the file: application/pdf (I am still researching ways to derive the mime type as it is not available as part of the jca.file properties). The screenshot of the BPEL process can be found here and the Assign activity can be found here.
The project source can be found at the following location. A sample pdf file to test the project and a screenshot of the BPM Human task screen after the successful creation of the instance can be found here.
References: [1] https://blogs.oracle.com/fmwinaction/entry/oracle_bpm_adding_an_attachment
© Oracle Blogs or respective owner