Create a Flow Using a Custom SOAP Connector – Part 3

This is the third and final post in our SOAP Custom Connector  series. 

In this article we’ll use the custom SOAP connector we created in parts 1 and 2 of this series, to create a Microsoft Flow that automates conversions using the on-premise version of the Muhimbi PDF Converter.

In this three-part series, we’ll cover the following topics:

  1. Creating a SOAP custom Connector using Postman (part 1).
  2. Creating a custom Connector using a Postman collection file and Integrating it with Microsoft Power Automate (part 2).
  3. Creating a Flow that can consume the SOAP Service (this post).

Prerequisites/Before we begin:

  1. Please make sure you have configured and deployed the connector with reference to these article.
  2. An Office 365 subscription with SharePoint Online license.
  3. Appropriate privileges to create Flows.


Now that we have all the prerequisites in place, lets get started:

From a high level, our Flow will look like the following:


Step 1: Open the Power Automate / Flow designer, create a Flow, and find the “When a file is created or modified (properties only)” trigger. This trigger will allow you to start the Flow by adding a file into a folder or when modifying a property of a file already in the folder. Naturally other triggers can be used as well (email attachments, drop box, OneDrive, you name it)

  • In the action, specify The Site Address to the SharePoint Online site-collection you want to monitor for new items.  Then, specify the Library Name within the site to monitor. The Folder within the library can optionally be specified as well.

Step 2: Add the SharePoint “Get file content” action to the Flow Canvas and configure it with reference to the details below:

  • Site Address: Specify the path to the SharePoint Online site-collection which holds the file to be converted.
  • File Identifier: “Identifier” the output from the “When a file is created or modified (properties only)” action.

Step 3a: The SharePoint “When a file is created or modified (properties only)” does not provide us the File extension for the file.  To get the file extension we need to perform the steps shown below.


Step 3b: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Name”.

  • Name: Set it to “Filename“.
  • Type: Set it to  “String”.
  • Value: Add “File name with extension” the output from the “When a file is created or modified (properties only)” action.

Note: If you are new to Power Automate (Microsoft Flow), please refer to the article on how to use expressions in flow actions.

Step 3c: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Name Length” .

  • Name: Set it to “Filelength“.
  • Type: Set it to “Integer” .
  • Value: Set it to Expression “length(variables(‘Filename’))“.

Step 3d: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get Extension Length”.

  • Name: Set it to “Extensionlength“.
  • Type: Set it to “Integer”.
  • Value: Set it to “Expression” “sub(variables(‘Filelength’),lastIndexOf(variables(‘Filename’),’.’))

Step 3e: Add the “Initialize Variables” action to the Flow Canvas and Rename it to “Get File Extension”.

  • Name: Set it to “Get File Extension“.
  • Type: Set it to “String”.
  • Value: Set it to “Expression” “substring(variables(‘Filename’),lastIndexOf(variables(‘Filename’),’.’),variables(‘Extensionlength’))“.

Step 3f: Add the “Compose” action to the Flow Canvas and Rename it to “Replace . From the Get File Extension”.

  • Inputs: Set it to “Expression”

replace(variables(‘Get File Extension’),’.’,”)“.

At the end of the above step we will  have the “File Extension” and we will use this in the “Convert Document” custom action.


Step 4: Add the “Compose” action to the Flow Canvas and Rename it to “Convert File Content in Base64“. This will take our input file and encode it into a format that is suitable for passing binaries as part of a SOAP request.

  • Inputs: Set it to “Expression” “base64(body(‘Get_file_content’))“.

Our “Convert Document” custom action expects the “Source File Content” as Base64 bit String.


Step 5: Add our Custom “Convert Action” to the Flow Canvas.

Configure it with reference to the details and links 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>@{outputs('Convert_File_Content_in_base64')}</ns:sourceFile>
         <ns:openOptions>              
            <ns1:FileExtension>@{outputs('Replace_._from_Get_File_Extension')}</ns1:FileExtension>   
            <ns1:OriginalFileName>@{triggerBody()?['{FilenameWithExtension}']}</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>

As part of the SOAP envelope we are passing a number of expressions that mean something to the Flow Editor. Make sure the relevant Flow actions have EXACTLY the same name as our example, otherwise make sure the expressions are updated to match yours.

The following expressions are used:

  • Source File:
    • <ns:sourceFile>@{outputs(‘Convert_File_Content_in_base64’)}</ns:sourceFile>.
    • Output of the “Convert File Content in base64” action.
  • FileExtension:
    • <ns1:FileExtension>@{outputs(‘Replace_._from_Get_File_Extension’)}</ns1:FileExtension>
    • Output of the “Replace . From the Get File Extension” action.
  • OriginalFileName:
    •  <ns1:OriginalFileName>@{triggerBody()?[‘{FilenameWithExtension}’]}</ns1:OriginalFileName>
    •  Output from the “When a file is created or modified (properties only)” action.


Step 6A: In the next three steps we will parse the XML that is returned by the SOAP requests. It contains the content of the PDF output file.

A sample SOAP output looks as follows

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<ConvertResponse xmlns="http://services.muhimbi.com/2009/10/06">
<ConvertResult>
JVBERi0xLjUNCiWDkvr+DQoxIDAgb2J......qDQo==
</ConvertResult>
</ConvertResponse>
</s:Body>
</s:Envelope>

In the above output we are only interested in <ConvertResult>. The actions below will help us extract the data.


Step 6B: Add the “Compose” action to the Flow Canvas and Rename it to “Xpath to Parse the XML“.

  • Input: Set it to Expression “xpath(xml(body(‘Convert_Action’)),’//*[local-name()=”ConvertResult”]/text()’)

The output of this action will be an Array.


Step 6C: Add “Compose” action to the Flow Canvas and Rename it to “Get first element in the array”.

  • Input: Set it to Expression “first(outputs(‘Xpath_to_Parse_the_XML’))

This will return the First element(Base64 String) of the Array.


Step 6D: Add the “Compose” action to the Flow Canvas and Rename it to “Replace double quotes from Base64 string“.

  • Input: Set it to “Expression“replace(outputs(‘Get_first_element_in_the_array(Base64)’),’”‘,”)

Step 7:  Use the “Create file” SharePoint action to create the PDF document in the SharePoint document library. Naturally other actions can be used as well to consume the generated PDF file. Send it as an email attachment, write it to DropBox, OneDrive, you name it.

  • Folder Path: Specify the output path to write the PDF file to.  Make sure this is different from the library of the input file to prevent ‘recursive’ flows.
  • File Name: “Name” the output from the “When a file is created or modified (properties only)” action.
  • File Content: Set it to “Expression”  

“base64ToBinary(outputs(‘Replace_double_quotes_from_the_Base64_sting’))“.

Note: The SharePoint “File Content” expects a Binary String, in the above step we converted the Base64 string to Binary using the expression we added to the “File Content”.


That’s it- you’re done!  Publish your Flow and upload a supported file type to the folder that is monitored by the configured SharePoint trigger. After a short wait, you can find the PDF in the output folder.

Given that all of this can be achieved using a standard connector and a single Flow action, invoking SOAP based web services is a lot more work. However, if you really need it, e.g. for reasons explained in part 1, then it is good to know the option is there.

Although in this example we are using Muhimbi’s SOAP based web service, the concept is exactly the same for solutions from other vendors.

In addition to converting files, Muhimbi’s SOAP Service also supports file merging, watermarking, applying security, file splitting and OCR. There is no need to follow all 3 articles in this series for each bit of functionality. You can simply reuse the custom connector created and pass the appropriate XML in for each command.

Figuring out the exact XML can be tricky. Talk to Muhimbi’s support team for details.


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

Leave a Reply

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

WordPress.com Logo

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

Google photo

You are commenting using your Google 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