06-15-2018 09:53 AM
Hi,
I am using the REST API client on CVP 11.5 which works fine.
It returns (and I log) back the XML response.
I then parse the XML for various parameters using SET Value & local variables and then log each local variable value but the values are not been set (they are blank).
I have checked the XPath using XPath Tester - and it is correctly selecting the element - so path format is correct.
Free Online XPath Tester / Evaluator - FreeFormatter.com
Anyone have any ideas?
Example Local Variable Myid
importPackage(com.audium.server.cvpUtil);
var xml= {Data.Element.Rest_SAP.response_body}
var path= "/entry/content/m:properties/d:IMyid"
XpathUtil.eval(xml,path);
XML Response is:
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://myserver.mydomain.com:8000/sap/opu/odata/sap/ZERP_UTLITIES_IVR_SRV/">
<title type="text">SO_DP_CHECKSet('10100101234')</title>
<updated>2018-06-15T14:58:43Z</updated>
<category term="ZERP_UTLITIES_IVR_SRV.SO_DP_CHECK" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="SO_DP_CHECKSet('10100101234')" rel="self" title="SO_DP_CHECK"/>
<content type="application/xml">
<m:properties>
<d:IMyid>10100101234</d:IMyid>
<d:EContactNo>01234567</d:EContactNo>
<d:EFlag>D</d:EFlag>
<d:ERejrsn/>
</m:properties>
</content>
</entry>
Activity Extract Log File below - I log the Local Variables in the Set Value element and set to Create "After"
All the local variables have a blank value.
Parse XML,enter,
Parse XML,custom,Myid,Success
Parse XML,custom,ContactNo,Success
Parse XML,custom,Flag,Success
Parse XML,custom,Rejrsn,Success
Parse XML,custom,Result,Success
Parse XML,custom,Local_ContactNo,
Parse XML,custom,Local_Rejrsn,
Parse XML,custom,Local_Myid,
Parse XML,custom,Local_Flag,
Gerry
Solved! Go to Solution.
06-15-2018 10:49 AM
I believe it doesn't like the ":" in the tags. If you change your code to this, it'll work:
importPackage(com.audium.server.cvpUtil);
//replace : with "" globally in the xml
var xml= {Data.Element.Rest_SAP.response_body}.replace(/:/g,"");
//modified path expression as the colon is now removed
var path= "/entry/content/mproperties/dIMyid";
XpathUtil.eval(xml,path);
06-15-2018 10:19 AM
Can you display the Javascript that's in your set value element?
Be aware that whatever is returned on the final line of the Javascript is what's assigned into the local variable.
Sent from my Verizon 4G LTE smartphone
06-15-2018 10:24 AM
Just saw your Javascript.
It's possible it doesn't like the d: and m: prefixes in the xml tags. Can you first do a string replace all, to remove those? Then run your result thru the xpath evaluation?
Sent from my Verizon 4G LTE smartphone
06-15-2018 10:49 AM
I believe it doesn't like the ":" in the tags. If you change your code to this, it'll work:
importPackage(com.audium.server.cvpUtil);
//replace : with "" globally in the xml
var xml= {Data.Element.Rest_SAP.response_body}.replace(/:/g,"");
//modified path expression as the colon is now removed
var path= "/entry/content/mproperties/dIMyid";
XpathUtil.eval(xml,path);
06-18-2018 02:25 AM
Wow! What would we do without you?
That was exactly the issue. It could not handle the colon character and your simple global replace did the trick.
Thanks so much.
I would consider this a bug? would you?
If so - I could log a TAC case and ask for TAC to create a bug ID for it.
Gerry
06-18-2018 05:33 AM
I suppose it's a bug. If xpath can parse it with colons, then vxmlServer should be able to as well. It would definitely make a parsing SOAP responses easier. So you may as well report it along with the workaround
thanks, Janine
Sent from my Verizon 4G LTE smartphone
06-20-2018 09:17 AM
In XML, when a field name is prefixed with some name and colon, it's called a namespace. It's valid XML, but usually very annoying for developers to work with no matter the context. Stripping it manually is a valid solution, though the underlying XML engine should be able to handle it gracefully.
06-22-2018 02:26 AM
I logged a TAC case for this issue and Cisco have now raised a enhancement defect id of CSCvk03994.
Gerry
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide