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 –
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://services.muhimbi.com/2009/10/06"
xmlns:ns1="http://types.muhimbi.com/2009/10/06"
xmlns:ns2="http://types.muhimbi.com/2014/02/06"
xmlns:ns3="http://types.muhimbi.com/2015/04/13"
xmlns:ns4="http://types.muhimbi.com/2010/05/17"
xmlns:ns5="http://types.muhimbi.com/2013/08/01"
xmlns:ns6="http://types.muhimbi.com/2013/01/14">
<soapenv:Header/>
<soapenv:Body>
<ns:Convert>
<ns:sourceFile>%PowershellOutput%</ns:sourceFile>
<ns:openOptions>
<ns1:FileExtension>%CurrentItem.Extension%</ns1:FileExtension>
<ns1:OriginalFileName>%CurrentItem.Name%</ns1:OriginalFileName>
</ns:openOptions>
<ns:conversionSettings>
<ns1:Format>PDF</ns1:Format>
<ns1:Fidelity>Full</ns1:Fidelity>
<ns1:ConverterSpecificSettings/>
<ns1:OutputFormatSpecificSettings/>
</ns:conversionSettings>
</ns:Convert>
</soapenv:Body>
</soapenv:Envelope>
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.