Web service processing of results transformation

502 views
Skip to first unread message

matthewda...@gmail.com

unread,
Jul 11, 2014, 5:47:15 AM7/11/14
to suppor...@runmyprocess.com
We have our own SOAP web service and we can send a request and get a result. The result body is currently in XML and we would like to get the content of the XML elements.

What we need to do is process the result of our web service, one of the difficulties is that we have a variable number of results (similar to an SQL query to a database where you could get an unlimited list of results)

How should we process the result in order to get them into our variables?

Richard Manga

unread,
Jul 11, 2014, 10:05:29 AM7/11/14
to suppor...@runmyprocess.com
Good morning,

To process your result (if it's in xml format), you can use "P_to_array" freemarker function.

The following documentation explains how to use this function:


Regards,

Richard



--
Fujitsu - RunMyProcess
---
You received this message because you are subscribed to the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to supportforum...@runmyprocess.com.
To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.
To view this discussion on the web visit https://groups.google.com/a/runmyprocess.com/d/msgid/supportforum/ce91e1ee-f8e0-42be-937e-544dc7a1a96c%40runmyprocess.com.
For more options, visit https://groups.google.com/a/runmyprocess.com/d/optout.

Matthew Daniels

unread,
Jul 11, 2014, 11:33:47 AM7/11/14
to suppor...@runmyprocess.com
Hi Richard and  thank you for the answer.  In the reference guide there is some example code:  but where dose it go, the instructions are not clear to me at all.



<#assign var1 = {"feed":{"entry":[{"title":"John"},{"title":"Mathew"}]}}> ${P_to_array(var1.feed,"entry")} //returns [{"title":"John"},{"title":"Mathew"}] <#assign var2 = {"feed":{"entry":{"title":"John"}}}> ${P_to_array(var2.feed,"entry")} //returns [{"title":"John"}] <#assign var31 = {"feed":{}}> ${P_to_array(var3.feed,"entry")} //returns []




You received this message because you are subscribed to a topic in the Google Groups "RunMyProcess Support Forum" group.
To unsubscribe from this topic, visit https://groups.google.com/a/runmyprocess.com/d/topic/supportforum/N4_jmxeYOG4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to supportforum...@runmyprocess.com.

To post to this group, send email to suppor...@runmyprocess.com.
Visit this group at http://groups.google.com/a/runmyprocess.com/group/supportforum/.

thoshino

unread,
Jul 14, 2014, 8:53:42 PM7/14/14
to suppor...@runmyprocess.com, matthewda...@gmail.com
Hi Matthew,

Coming back to your original question, if your API returns XML object, RMP server might be able to parse it automatically for you, then you will be working with JSON by default.
To check this, make a connector for your SOAP API, and set "Result Format" to XML.
You can test launch this, and if you see a layered object in the result, you are good to go.

And then comes to the question about a node of your data object having 0, 1, or more than 1 object.
This is "array" structure, and you will run into Freemarker syntax errors if you don't know what it will be.
I mean, if it is 0 or 1, it is not an array, it is just a text data, thus my_var[0] will get syntax error.
To avoid this, you can use P_to_array.

The example you saw there, you can copy&paste the exact line into an Output variable of your connector activity, and "Test" in the Freemarker scripting window.
It is supposed to show you how P_to_array reacts to each secnario (0, 1, or multiple).

Now, how you should apply this to your application is:

1. Check  that you can get the XML data as JSON data automatically 

2. Understand which object have dynamic number of nodes (in the example, it is feed.entry).

3. In Output variable of your connector activity, defined a variable name, and for this write something like
${P_to_array(P_result.entry.feed)}
P_result is the parent node for all data coming from activity, including Connectors.

I hope this helps!

Best regards,

Taka
Reply all
Reply to author
Forward
0 new messages