Wednesday, October 5, 2022

Improving the send action with multipart support

Sending data with Orbeon Forms

Orbeon Forms features simple processes, which combine actions and conditions, and which are usually associated with buttons at the bottom of a form. One of these actions is the send action, which allows sending form data in XML and PDF formats, in particular, using HTTP, to a service endpoint.

However, each send action can only send a single file. This is limiting especially because form data can come with attachments, added to a form through the use of one of the Attachment controls, and it would be useful to be able to send out those attachments alongside the data.

Adding multipart support

So with Orbeon Forms 2022.1, we are enhancing the send action with the ability to send multiple items to a service endpoint in a single HTTP request using a so-called multipart request format. This allows sending XML data with its attachment, and even to add a PDF file or an Excel export to that. You select the content to send using tokens. For example the following sends the XML data, its attachments if any, and the dynamically-generated PDF file:

    uri     = "",
    method  = "POST",
    content = "xml attachments pdf"

The request body might look like this:

Content-Disposition: form-data
Content-Type: application/xml; charset=UTF-8
Content-Transfer-Encoding: binary

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:fr="" fr:data-format-version="4.0.0">
        <pet-picture filename="cat.jpg" mediatype="image/jpeg" size="56803">cid:94b0e57e87fa8f42cb494fdc2808f58c5b31be41</pet-picture>
Content-ID: <94b0e57e87fa8f42cb494fdc2808f58c5b31be41>
Content-Disposition: attachment; filename*=UTF-8''cat.jpg
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

...binary image content here...
Content-ID: <7a361b305064d3a95511da35a8c53edbabe3af8b>
Content-Disposition: attachment; filename*=UTF-8''My%20demo%20multipart%20form%20-%20ce85cc4b7be9975d.pdf
Content-Type: application/pdf
Content-Transfer-Encoding: binary

...binary PDF content here...


The multipart format is automatically selected on the wire if more than one item needs to be sent. On the receiving side, a lot of software can decode a multipart request and extract the individual parts.

For more details, see the documentation.

We hope you will find this Orbeon Forms 2022.1 feature useful!

No comments:

Post a Comment