Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Is it possible to access a html based web service from a pdf form?

Avatar

Level 2

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!

1 Accepted Solution

Avatar

Correct answer by
Level 10

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

View solution in original post

3 Replies

Avatar

Level 3

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.

Avatar

Correct answer by
Level 10

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

Avatar

Level 2

Thanks!

It took some manipulating but it ended up working.