Wednesday 5 November 2008

Attachments with Integration B2B

In Integration B2B, escpecially with the ebXML adapter, you can send multiple attachments.

Attachments can be of any type, both binaries as well as ASCII-files. There can be multiple files that will be send together with a payload. The payload however is mandatory, so you
can't just send a message with attachments, but without a payload.

To send attachments you have to make-up an attachment-xml document with the following structure:
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2005 sp1 U (>
<Attachments xmlns:xsi="" version="1.0" boundary="boundary---">

As you can see there can be several attachment-parts. The attachment-part as shown can have a location-element in which you provide a valid url to the particular file. It can also have an element with the content Base64-encoded. This is particular the case when receiving attachment while B2B is not directed to put the received attachments in a file-folder.

To be able to send files with a particular mimetype, you have to set a property in the file:

oracle.tip.adapter.b2b.MimeType=application/xml : application/octet-stream : application/EDIFACT : application/EDI-X12 : application/jpg : image/jpeg : application/gzip : application/x-gzip : application/pkcs7-signature : application/pdf

Here you can add additional mime-types you need. It appears that B2B has a quite limited standard list.

Another important property is the following:

Here you can denote where B2B has to put the received attachments. On receive of the message it will place the file there and in the attachment.xml document in the ip-message-type it will denote which attachments it received.

If you do not give up a directory then it will put the received attachments Base64-encoded in the attachment.xml in the ip-message-type on the queue.


Unknown said...

Hi Martien,

The article is really informative. I need one clarification from you.
How can we send the attachment documents from BPEL to B2B.
We have a requirement of sending an attachment(any type of file) along with an invoice from BPEL to B2B on Rosettanet.

The attachment is saved as CLOB(It is in base64 format) in Database and from BPEL using a DB adapter we are pulling the CLOB. This CLOB has to send along with the invoice to B2B.

Could you please provide ur inputs.

Appreciate ur help!!


Martien van den Akker said...

Hi Dibya,

This is not that hard, really.
You have actually two options.
1. Since you have the attachment already in Base64 format you could put it as is in the attachement-xml. I don't have an example of the attachement with an inline base64 content at hand. But this is easily created if you're able to send a test-message with an attachment to a b2b server. If you unset the attachements-dir property in of the receiving B2B, you get an example attachment xml in the queue with the attachment base64 encoded.
2. You can save the attachement in the proper binary format (base64-decoded in your case) with the file adapter (us an opaque schema) to a location that is accesible to B2B. Then you can use the attachement.xml used in my blog. The file may be on a filesystem that is accesible to B2B, but it may also be on a HTTP-server. Then the location should be a http-url.

See also:

In your case I would choose option 1. But you have find an example of the base64-variant of the attachment.xml. I know I would be able to create one, but that takes too much time for me right now. With my hint above I think you should be able too.