Invoke SOAP API using Power Automate Desktop to Convert, Merge, Watermark, Secure & OCR files

This is the second post in our “Invoke SOAP WebService using the Power Automate Desktop(RPA)” series.

In this article, we’ll “Invoke the SOAP WebService” and design a Solution using Power Automate Desktop that automates the conversion process.

Before we begin, please make sure the following prerequisites are in place:
  • Install and configure a Windows Server with a public-facing IP address. This may be a server in your own data center or a VM in AWS or Azure.
  • Download the fully functional free trial of The Muhimbi PDF Converter Services here.
  • Please make sure the software is installed exactly as described in chapter 2 of the Administration Guide. Please follow that guide to the letter and make sure you pay particularly good attention to the section about ‘dependencies’. The Administration Guide is included in the download and available online here.
  • Power Automate Desktop should be installed on the VM which can connect to the WebService.

From a high level, our Power Automate Desktop solution would look like the screenshot below

Step 1:

Launch the application and select New flow in the console. Enter a name for the Desktop flow, and select Create.

Step 2:

Add the “Get files in folder” action to the Power Automate Desktop designer canvas.

  • Folder: Add the Folder Path to the Folder you want to Convert and click on “Save”

Step 3:

Here, we will use the ‘For each’ loop to loop through multiple files, one at a time.

  • Add the ‘For each‘ action to Power Automate Desktop designer.
  • Value to Iterate: ‘%Files%‘ output of the ‘Get files in folder‘ action.

Step 4:

In Power Automate Desktop you can execute Python, VB, and JavaScript code samples. In this example we will use PowerShell Code to Convert a File to a Base64 string, which we will use in the Invoke Web Service action.

Inside the ‘For each’ loop add the ‘Run PowerShell script‘ action.

[convert]::ToBase64String((Get-Content-path "%CurrentItem%"-Encoding byte))

Step 5:

Inside the ‘For each’ loop add Build the SOAP request with reference to the screenshot below –

Paste the Request body below –


Note: We are using dynamic variables in the above SOAP envelope i.e. %PowershellOutput%, %CurrentItem.Extension% and %CurrentItem.Name%

Step 6:

Inside the ‘For each’ loop add the “Execute Xpath Expression”  to the Power Automate Designer Canvas and configure it with reference to the details below:

  • XML document to parse:%SoapServiceResponse%
  • XPath query: //*[local-name()=”ConvertResult”]/text()

Step 7:

The response returned by Muhimbi Service(pdf) is a Base64 string. In this step, we will convert the Base64 string to a file and write the file back to the destination folder using Power Code.

Inside the ‘For each‘ loop add the ‘Run PowerShell script‘ action.

[IO.File]::WriteAllBytes("C:\Users\clavin.fernandes\Desktop\PDFs\%CurrentItem.NameWithoutExtension%.pdf", [Convert]::FromBase64String("%XPathResults%"))

That is it, run the Power Automate Desktop Flow. After a short wait, you will see PDF files in the destination directory.

Subscribe to this blog for the latest updates about SharePoint Online, Nintex, Microsoft Flow, Power Apps, and document conversion and manipulation.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s