flexer7661
flexer7661

Reputation: 97

How to consume a RESTful web service using browser technologies

So i've developed a simple Java restful webservice and it's running on http://localhost:8080/testProject/rest/items.

When I navigate to that URL in a broswer I get XML back.

So what would be the best way to consume the Web Service and display the result in a user friendly way, in a table for example.

Should I use basic HTML or jquery or something for this?

I will also be looking to post parameters to the web service in the future.

Thanks

Upvotes: 0

Views: 2398

Answers (3)

web-nomad
web-nomad

Reputation: 6003

Restful services are meant only to consume data from the server and display those to the user. If you are also looking to post data back to the server, you may want to look at other options...(curl, soap, xml-rpc) with proper auth checks so that malicious data is not posted back to the server / database.

Now, back to your original question, you have got an xml response back and you want to show the results to your users, you can use XSLT to do that, or you can just parse the xml on the server side and use to display it to your users.

Upvotes: 0

Hubro
Hubro

Reputation: 59333

To display XML files nicely in the browser, XSLT is what you're looking for. You can use XSLT to transform XML documents into HTML, so you can display nice tables and pretty styles. Wikipedia on XSLT:

XSLT (Extensible Stylesheet Language Transformations) is a declarative, XML-based language used for the transformation of XML documents. The original document is not changed; rather, a new document is created based on the content of an existing one.[2] The new document may be serialized (output) by the processor in standard XML syntax or in another format, such as HTML or plain text.[3] XSLT is most often used to convert data between different XML schemas or to convert XML data into web pages or PDF documents

It's quite simple to get started. I recommend using W3Schools: http://www.w3schools.com/xsl/

Hope that helps

Upvotes: 1

Justin Ethier
Justin Ethier

Reputation: 134167

You can do this easily with jQuery.get.

Upvotes: 0

Related Questions