MuleSoft — SOAP WSC Connector file upload strategies

Arun Dutta
The Mule Blog
Published in
4 min readMay 25, 2020

Although most of the API’s that we interact with nowadays are REST based microservices endpoints, but there are plethora of legacy SOA applications who are still exposing SOAP webservices for them to be consumed to interact with backend data which resides on systems like mainframe, oracle databases etc.

In order to consume such webservices Mule 4 provides the all new WSC Connector. In this article we will discuss the ways via which we can use the connector to upload files to the webservices.

Older versions of Apache CXF connectors used in Mule 3 are no longer supported in Mule 4.

There are two ways you can upload file via WSC connector in Mule 4:

  • Inline attachments — Works well if the attachment is of small size (≤2MB) as this approach converts the file data into base64 encoded form and then attaches it to SOAP request.
  • Multipart attachment — Inline technique will fail if the file size is large (>2 MB). In that case we need to use the inbuilt multipart attachment method of the connector.

I will take an example of file attachment to an Oracle HCM server for this tutorial for a very well known service importBulkData. Reference for Oracle SOAP request envelope can be found on Oracle community here and here

Inline Attachments

The flow below polls for an incoming file from an SFTP server and then compressing it to a zip before uploading it to Oracle HCM as inline attachment.

DWL which has been used to generate SOAP request

The SOAP request is provided by the SOA importBulkData contract and the corresponding DWL is shown above. You can only focus on the erp#Content section which has payload assigned. This will automatically convert the .zip file payload from the previous Archive processor into a base64 encoded form during runtime.

And that’s it, your file will be uploaded to the destination system.

Details about configuring the WSC Connector credentials can be found on the mulesoft documentation links given in the reference section.

Multipart Attachments

The flow remains as the one attached above, but the DWL will change and we will use the <wsc:attachment> tag to attach the zip file.

erp#Content section has been modified with a reference value of the file name

As you can see in the above DWL, the content is no more the payload but a reference to the payload with reference name as the name of the file (attributes.fileName) and the actual payload is passed the attachment section of the connector as shown below.

Assuming the readers are aware of the Mule parameterization and p(‘xyz’) in the DWL are static values configured in the config.yaml file.

Multi part attachment using WSC Connector

The above modification will automatically attach the file as multipart attachment and upload the file to the webservice.

The above multipart attachment technique is tested to work on WSC Connector version 1.5.8,previous versions had issues with multipart attachments, details of which can be found here. Mule version tested on are 4.2.2 and 4.3.0.

--

--

Arun Dutta
The Mule Blog

3x Microsoft Certified (Azure Solutions Architect)| 2x MuleSoft Certified (Integration Architect/Developer)| Java/Microservices/NodeJS Certified