Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Invoke Servlet from JavaScript

Avatar

Level 2

Hi,

Is it possible to invoke a Servlet and retrieve its response using Designer's JavaScript API? I've seen the xfa.host.gotoURL method which allows you to invoke a URL with a query string. However, as this does not return a response then it doesn't seem to be the way to go. What are my alternatives here?

Is invoking a WSDL and using the SOAP object my only alternative here?

Thanks.

Ray

6 Replies

Avatar

Level 10

Yes ....you woudl use a Submit button to call your servlet (no different than a web page). If you want to return something it is important to know how your PDF is being housed. If it is in a browser then you can return HTML and the browser will interpret the page. If you are in a standalone app like Acrobat/Reader then you must return a PDF response (otherwise the application will not know what to do with the HTML that you woudl normally send).

Paul

Avatar

Level 2

The PDF will be housed within a browser. However, it's not necessarily HTML I'd be returning. I'd be using my Servlet to perform some server-side computation that would then be used by my JavaScript to, for example, determine the presence of various buttons. In this case, will the Submit button approach suffice. Again, if not, what would be an alternative?

Thanks.

Avatar

Level 10

If you want the servlet to "communicate" with the form then the best way is to create a Web Service.

The submit approach is used when the user has finished with the form and wants to move the information onto the next step in the process.

Paul

Avatar

Level 2


OK, that makes sense. Is it possible to submit the document's contents as well as part of the web service request? Another operation I'd possibly require would be the ability to pass the document's contents and one or more parameters to a web server, and then deal with the corresponding response.

Thanks.

Avatar

Level 10

Yes but it is not straight forward to get the doc ument into a Soap response ....there was a post that described this not too long ago. Have a search and see if you can find it.

Paul

Avatar

Level 2

For those that are interested I think this is the link that you were referring to: http://forums.adobe.com/message/2039661#2039661

Which brings me on to my next question. Which JavaScript object should I be using to invoke a Web Service from in my LiveCycle Designer created XDP?

I was under the impression that Net.SOAP.connect or SOAP.connect would work in a Readers Extenstions-enabled environment but haven't had any success in using these yet. Can anyone point me in the right direction please?

Thanks.