Sunday, March 25, 2012

Attachment Handling using Oracle Service Bus (OSB)

1. Introduction

                             Oracle Fusion 11g is an enterprise ready family of integration products from Oracle.  Oracle Service Bus (OSB) 11g  is one of the components in Fusion middleware product.  OSB can do routing, transformation and orchestration of messages. Messages can be of xml or non xml.  Here we are concerned about sending files as attachments along with the messages.  We will discuss how OSB handles attachments and the configurations done for the same and the results of one sample performance testing done in virtual data center (VDC) Linux environment.

2. Introduction to Attachment handling

            You might be remembering that in your company if you face any issues in your system, you might be asked to upload any screenshot of the problem or any documents relevant to that. Did you ever think that how these files are processed in the background.
If you analyse closely, the files you upload will be first taken by some front end application and it will be passed on to the integration middleware component and there it will be uploaded into some file server or vendor specific share point.
            In this document, we are concerned only about the integration middleware component, OSB 11g and how it handles attachment.

3. Types of Attachment handling

            Attachment handling can be of two types.
a.       Inline attachment handling
b.      MIME attachment handling

a.       Inline attachment handling
Here the attachment file will be encoded into some format, say base64 format and send it as part of the main xml message

b.      MIME attachment handling
Here the attachment will be send as part of attachment headers along wth the normal xml message. The attachments can be received in multiple formats by OSB, but one of the common format is base64 encoded binary format.

4. Configuring OSB 11g for inline attachment handling

     Open OSB eclipse and create one Oracle Service bus project.

Create one proxy service inside AttachmentHandlingTest OSB project

Go to the message handling tab and select the following
a.       XOP/MTOM
b.       page attachments to disk

Now go to the MessageFlow tab and add some pipeline pair.

Deploy the application to the server

Testing the application.

Request document to test. The attachment (embedded in the attachment tag)  is encoded as base64.


5.Configuring OSB 11g for MIME attachment handling

    MIME attachments are the attachments send as headers. Here the client used for posting is soapUI. We should not use the sbconsole test window to test MIME attachment applications.

If we post via soapUI, OSB receives it as binary and we can see only some java reference for this object. Inorder to access this attachment there are  two ways.

1. Using Proxy service
2. Using Java code

1. Using Proxy Service - 

    Here you will receive the headers in the $attachments variable and there you can see the attachment as header. Now create a proxy service which takes request as binary and response as text and pass the attachment binary reference to this proxy service and get back the response as text.

Please find below the screenshots.

This is the sample proxy service

Assigning the binary-content from the $attachments variable for passing it to the proxy which converts binary to text

This is the proxy which converts binary to text. See the configuration in the "Messaging" tab.

In the binary to text proxy. we will give only empty proxy. See below

Calling the converter proxy from the main proxy. The text output will be saved in the response variable as shown below

Testing Using SOAPUI

  We have to post the MIME attachment using some 3rd party tool like SOAPUI. You require one wsdl for this.There are options to add attachments with different properties. Please find below the screenshot for the same.

2. Using Java Code - <<will update soon>>

For any queries , please drop a mail to or