Hello,
I have a requirement to use an XPath expression in the form of a string to grab elements from SOAP request and response payloads. The XPath expressions are stored in a KVM so we will extract them and map them to a flow variable.
I have tried using this inside of an Extract Variable policy but it seems like the policy doesn't support variable referencing. I believe this is achievable via Javascript using document.evaluate. However, I don't think JS scripts within Apigee have access to the document object.
What is the best way to do this?
Thanks!
Hmmmmmmm, that's an unfortunate limitation.
I cannot think of a simple way to do what you want.
We didn't consider that scenario with extractVariables, nor the static functions within Message Template. (Frustrating: there is a jsonpath() function, but no xpath() function).
As a workaround you could:
That's a longer way around, but it might work for your purposes.
Another alternative is to write a Java callout.
Thanks for the response, Dino.
Going with the workaround, we'd have to convert the xpath to jsonpath. For the sake of saving time and avoiding compatibility issues/conversion issues, I will most likely resort to writing a Java callout.
In your experience, which approach would result in a more efficient runtime?
feature request reference: b/123246424
My guess is that the Java callout would be more efficient, if it is carefully coded.
If you like I can provide you something to start with. I have a callout that does an xpath-and-encrypt. I would have to simplify it a little, to get your desired "extract xpath" capability.
EDIT: ok, I've produced a callout that does this. https://github.com/DinoChiesa/ApigeeEdge-Java-Xpath
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |