Results 1 to 3 of 3
Thread: How web service return xml?
- 10-07-2010, 05:56 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
How web service return xml?
Hi everyone. I am new to the forum and java too. :) Forgive me for my English. I am from Greece.
I have made a web service that gathers some data from a database and then returns them as a XML schema. They way i've done tha is by puting the data into a domdocument and then puting the document's content into a string object and return it.
My goal i to invoke the web service via a .jsp client and take this xml ( that web service returns) from the HTTP response body.
Is it correct to return the xml as string??
Do you have any idea how to get the HTTP response body and manipulate it??
thanks
- 10-08-2010, 02:26 AM #2
for inside the JSP, I would use the StAX API for writing the XML. this has the functionality similar to DOM, except likely better for using less memory than DOM.
and on the client side, the HTTP client, you may also use StAX API to parse the XML from the input stream as the http client is reading it.
StAX is a more recent to Java (than since Java was first created) XML api. as of java 1.6 it is built into the JRE (no additional jar file needed).
- 10-08-2010, 10:07 AM #3
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
For starters I wouldn't do this in JSP.
It's not what JSPs are for.
I hope at the least you are not writing this code directly onto the JSP page, and have it in its own class?
Anyway, I've seen XML transferred in the way you describe plenty of times. It can make sense (ie you are sending the xml to be saved as-is in a db, or are retrieving such xml).
Similar Threads
-
Using a Web Service
By ragnor2004 in forum Advanced JavaReplies: 12Last Post: 02-06-2010, 01:57 AM -
Web service
By mousumidas in forum Advanced JavaReplies: 3Last Post: 01-28-2010, 10:12 AM -
how to call service method inside another service
By kirtichopra2003 in forum Web FrameworksReplies: 1Last Post: 10-24-2009, 03:19 AM -
Consuming web service with return custom object
By dream_ in forum NetworkingReplies: 1Last Post: 04-16-2009, 07:56 AM -
Web Service from JSP
By Eric in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 07-02-2007, 06:00 PM
Bookmarks