webMethods.io Integration submitting and receiving the mime data

Introduction

This article explains how to submit and receive mime data using flow service.

Pre-requisite

It is assumed that readers of this article know how to create integrations on webMethods.io integration.

What is MIME?

  • Multipurpose Internet Mail Extensions (MIME) is the acronym for Multi-Purpose Internet Mail.
  • It’s an extension of the Internet email protocol that lets people send, receive, and exchange different data files, such as images, audio, and video, over the Internet
  • In the HyperText Transfer Protocol (HTTP) for the World Wide Web, servers insert a MIME header field at the beginning of any Web transmission.
  • Clients use the content type or media type header to select an appropriate viewer application for the type of data indicated.

For more details, please refer to

What are MIME headers?

  • MIME headers appear at the beginning of a MIME message as well as within the separate body parts.
  • Some MIME headers can be used both as message headers and in MIME body parts. Some additional headers are defined for use only in body parts.

For more details, please refer MIME Headers | Microsoft Learn.

MIME capabilities?

  • MIME defines a message format that allows for:
  • Textual message bodies in character sets other than US-ASCII.
  • Non-textual message bodies.
  • Multipart message bodies.
  • Textual header information in character sets other than US-ASCII.

MIME message structure

  • A MIME message has two main parts: the header and the body
  • The message body consists of body parts of different types, depending on the demands of the data in the message.
  • Basic part. Includes all Basic MIME body part types: text, image, audio, video, and application. It does not include the Message-part or Multipart types. This is the simplest part.
  • Multipart. The container part is made up of two or more sub-body parts. The Multipart type includes several subtypes that describe how the sub-parts relate to each other (mixed, alternative, digest, and parallel).
  • Message part. The message is used as an attachment, for example, a message forwarded in another message.

Use Case

  • In our use case, we will see how we can receive the multipart data\form message from a third-party client and upload it to any temporary cloud storage location.
    Later, we will see how we can post the multipart message from flow service to third-party HTTP endpoints.

Receive the multipart form data from a third-party client

  • In this case, we will receive the data from Postman client and upload the data to Azure cloud storage.

Steps followed in the flow service to get the mime data:

  • getHttpRequest: Getting the request details like header details, request URL and method.

  • MergeHeaderAndBody: Merge the body content and header content and create a stream as output.

  • CreateMimeData: Produces a MIME object from a MIME message stream.

  • GetNumParts: Reports the number of body parts in a MIME object.

  • GetBodyPartContent: Retrieves the content from a specified body part in a MIME object. Body part content can be extracted from mime data using the index.

  • Put Blob Data in Azure Storage: Upload the body content part to some third-party storage location. In our case, it will be Azure storage location.

Testing Using the Postman client

  • Configure the HTTP endpoints of flow service on webMethods.io integration flow service.

  • Submit the form data from the postman client.

Note: Attached is the postman collection and flow service used for receiving the data in flow service and uploading it to Azure cloud storage.

UploadBulkMImeData.zip (10.1 KB)

MimeData.postman_collection.zip (782 Bytes)

Post the multipart data from our flow service to some third-party endpoints.

In this use case, we can submit the data to third-party end points either by flow service or workflow.

Submit the form data using the flow service

Flow Description:

  • In this flow service we will pull the CSV data from Azure storage and then we will submit the same data to the third-party end points using the multipart approach.
  • CreateMimeData: In the CreateMimeData we are adding the mime headers initialized in the previous step

  • GetData from source location: In this step, we are pulling the data from the Azure storage location, and the same data will be sent to the third-party HTTP endpoints.

  • AddBody part: Adds a body part (headers and content) to a specified MIME object.

  • GetEnvelopeStream: Generates a MIME message from a MIME object.

  • HTTP client: Submits the request to the third-party endpoint.

Note: Attached is the flow service used for submitting the csv to the third-party endpoints.

SubmitCSV-MimeData.zip (10.6 KB)

  • For testing purposes in the HTTP client, I have configured the endpoints for one of my flow services.
    So when my flow service submits the request to the HTTP endpoint, it will invoke another flow which takes the form data.

Points to remember:

  • In our case, we have added only a single csv file and created mime data for it. We can have multiple such files added.
  • Attached are the flow services and postman collection used for creating this use case.
  • Please unzip the postman collection before importing in postman client.
  • As we have used Azure storage in the flow services, we need to create the account while importing the flow services.