cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Extract text from the response body of a SOAP service

Hello,

I need help with the following scenario:

I have a flow that consults a SOAP service of my company to obtain some data about the employees, specifically information about their vacation periods. The query returns well without problem, the Body of the answer is in XML format which I store in a variable.

 

Then here is my problem, the image is the response of the SOAP service. I need to extract the text of the following data: <DiasVacaciones> 40 and <DiasTomados> 16, the values ​​40 and 16 I must store them in another variable and then return them.

 

SOAP-1.png

SOAP-2.png

Can someone tell me how I can achieve this.Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Hola!

Your variable is called 'Redactar' and is of type string (cadena) right?

 

I can think of two approaches:

1.- first one is to see if SOAP response has proper XML format, you can use the following expression to evaluate it:

 

 

 

xml(variables('Redactar'))

 

 

 

If malformed xml, flow will fail. If proper xml, you can use xpath() based expression to read XML nodes inside. Either you can search in the Power Automate Community for 'xpath' to find different examples on how to use it... or you share an example of the whole SOAP response as you store it in your variable in this same thread and we can suggest a more precise expression

 

2.- As a workaround, and assuming <DiasVacaciones> node is always present in the response and just once, you can consider the SOAP response as a text, and use text manipulation WDL functions, like split(), so you can try with the following expression:

 

 

 

first(split(last(split(variables('Redactar'),'<DiasVacaciones>')),'</DiasVacaciones>'))

 

 

 

Same approach for DiasTomados

 

 

 

first(split(last(split(variables('Redactar'),'<DiasTomados>')),'</DiasTomados>'))

 

 

 

 

¡Ánimo!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

2 REPLIES 2
Super User III
Super User III

Hola!

Your variable is called 'Redactar' and is of type string (cadena) right?

 

I can think of two approaches:

1.- first one is to see if SOAP response has proper XML format, you can use the following expression to evaluate it:

 

 

 

xml(variables('Redactar'))

 

 

 

If malformed xml, flow will fail. If proper xml, you can use xpath() based expression to read XML nodes inside. Either you can search in the Power Automate Community for 'xpath' to find different examples on how to use it... or you share an example of the whole SOAP response as you store it in your variable in this same thread and we can suggest a more precise expression

 

2.- As a workaround, and assuming <DiasVacaciones> node is always present in the response and just once, you can consider the SOAP response as a text, and use text manipulation WDL functions, like split(), so you can try with the following expression:

 

 

 

first(split(last(split(variables('Redactar'),'<DiasVacaciones>')),'</DiasVacaciones>'))

 

 

 

Same approach for DiasTomados

 

 

 

first(split(last(split(variables('Redactar'),'<DiasTomados>')),'</DiasTomados>'))

 

 

 

 

¡Ánimo!



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Excellent, it worked correctly. Thanks

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (95,398)