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.
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:
send( uri = "https://httpbin.org/anything", method = "POST", content = "xml attachments pdf" )
The request body might look like this:
--CHZ6Pogx-A1VVuDgU22pcJASumg8S0CrOZhooqlw 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="http://orbeon.org/oxf/xml/form-runner" fr:data-format-version="4.0.0"> <my-main-section> <first-name>Bob</first-name> <pet-picture filename="cat.jpg" mediatype="image/jpeg" size="56803">cid:94b0e57e87fa8f42cb494fdc2808f58c5b31be41</pet-picture> </my-main-section> </form> --CHZ6Pogx-A1VVuDgU22pcJASumg8S0CrOZhooqlw Content-ID: <94b0e57e87fa8f42cb494fdc2808f58c5b31be41> Content-Disposition: attachment; filename*=UTF-8''cat.jpg Content-Type: image/jpeg Content-Transfer-Encoding: binary ...binary image content here... --CHZ6Pogx-A1VVuDgU22pcJASumg8S0CrOZhooqlw 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... --CHZ6Pogx-A1VVuDgU22pcJASumg8S0CrOZhooqlw--
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!
Post a Comment