I was wondering if it is possible to send a query from livecycle to web service and parse the return data.
An quick example of what I am thinking is querying a database like wolfram alpha using their html query.
It is in the format http://api.wolframalpha.com/v2/query?input=pi&appid=XXXX. where "pi" is the query and XXXX is the specific user id
The website then returns a xml file.
Is there anyway to send out that html with any query from a text field and process the response?
Thanks!
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
Naseko is right in using the formcalc get function, and I use this for accessing information from google calendar, you can also call the formcalc get function from JavaScript as described here http://blogs.adobe.com/formfeed/2009/02/calling_formcalc_functions_fro.html.
The main problem I have is with the yellow message bar message and popup saying do you want to allow access to api.wolframalpha.com (or whatever). I think you can get around this by certifing the form, but I don't have access to the servre products to do that.
Anyway, if it helps have a look at https://workspaces.acrobat.com/?d=vFcW-9OVSm*BdV6GyFfUIg you will need to modify the button click code to specify your own appid but the code is simple enough;
var response = FormCalc.Function.Get("http://api.wolframalpha.com/v2/query?appid=<<appid>>&input=capital%20of%20australia");
response = response.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "");
var responseNode = xfa.datasets.createNode("dataGroup", "response");
responseNode.loadXML(response, false, false);
var answer = responseNode.resolveNode("queryresult.pod.(title.value=='Result')").subpod.plaintext.value;
console.println(answer);
So this code sends a query "capital of australia" and gets a response "Canberra, Australian Capital Territory, Australia"
Replace <<appid>> with your appid and look at the linked sample to see how FormCalc.Function.Get works.
Also, expect Designer to crash a few times while getting it to work.
Hope this helps,
Bruce
Views
Replies
Total Likes
FormCalc has get post and put methods, maybe they'll help you:
http://help.adobe.com/en_US/livecycle/9.0/FormCalc.pdf look at page 79
An example from the book:
Get("http://www.myweb.com/data/mydata.xml") XML data taken from the specified file.
Get("ftp://ftp.gnu.org/gnu/GPL") The contents of the GNU Public License.
Get("http://intranet?sql=SELECT+*+FROM+projects+FOR+XML+AUTO,+ELEMENTS") The results of an SQL query to the specified website.
Views
Replies
Total Likes
Hi,
Naseko is right in using the formcalc get function, and I use this for accessing information from google calendar, you can also call the formcalc get function from JavaScript as described here http://blogs.adobe.com/formfeed/2009/02/calling_formcalc_functions_fro.html.
The main problem I have is with the yellow message bar message and popup saying do you want to allow access to api.wolframalpha.com (or whatever). I think you can get around this by certifing the form, but I don't have access to the servre products to do that.
Anyway, if it helps have a look at https://workspaces.acrobat.com/?d=vFcW-9OVSm*BdV6GyFfUIg you will need to modify the button click code to specify your own appid but the code is simple enough;
var response = FormCalc.Function.Get("http://api.wolframalpha.com/v2/query?appid=<<appid>>&input=capital%20of%20australia");
response = response.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, "");
var responseNode = xfa.datasets.createNode("dataGroup", "response");
responseNode.loadXML(response, false, false);
var answer = responseNode.resolveNode("queryresult.pod.(title.value=='Result')").subpod.plaintext.value;
console.println(answer);
So this code sends a query "capital of australia" and gets a response "Canberra, Australian Capital Territory, Australia"
Replace <<appid>> with your appid and look at the linked sample to see how FormCalc.Function.Get works.
Also, expect Designer to crash a few times while getting it to work.
Hope this helps,
Bruce
Views
Replies
Total Likes
Thanks!
It took some manipulating but it ended up working.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies