Results 1 to 3 of 3
  1. #1
    nikos is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default 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??


  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    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).

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power


    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

  1. Using a Web Service
    By ragnor2004 in forum Advanced Java
    Replies: 12
    Last Post: 02-06-2010, 01:57 AM
  2. Web service
    By mousumidas in forum Advanced Java
    Replies: 3
    Last Post: 01-28-2010, 10:12 AM
  3. how to call service method inside another service
    By kirtichopra2003 in forum Web Frameworks
    Replies: 1
    Last Post: 10-24-2009, 03:19 AM
  4. Consuming web service with return custom object
    By dream_ in forum Networking
    Replies: 1
    Last Post: 04-16-2009, 07:56 AM
  5. Web Service from JSP
    By Eric in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 07-02-2007, 06:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts