views:

86

answers:

1

Hello All,

I wrote a RESTful webservice using JAX-RS API, that returns an XML string.

I am trying to write another RESTful webservice that takes in this XML string, does parsing of it using DOM and extract particular things I want. The XML string happens to be very long so I do not want to pass it as a @QueryParam or @PathParam.

Say If I write that XML string into a file, How do I go about writing this service that takes in this file, extracts whatever I want and return the results. I am actually trying to extract some number of strings, so my webservice should finally return an array with all those strings.

Could somebody please shed some light on how I should go about doing this.

Thanks in advance

+1  A: 

Sashikiran,

not sure I understand this correctly, but you can implement streaming access to the HTTP output and input streams. You need not read or write the whole thing at once.

So, while your read the stream from service A you can extract what you need and write that out to service B via a POST request.

Why are you DOM-parsing the XML? A SAX or StAX parser seems more suitable of the XML is indeed very long.

Jan

Jan Algermissen
Thanks Jan. Well I had earlier used DOM so was using it, no partucular reason. But heard its not good in performance compared to SAX or StaX parser. Will try to use those.
Sashikiran Challa