Sashi Kiran Challa
Sashi Kiran Challa

Reputation: 905

How to pass a very long string/file into RESTWebservice JAX-RS Jersey

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

Upvotes: 1

Views: 856

Answers (1)

Jan Algermissen
Jan Algermissen

Reputation: 4978

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

Upvotes: 1

Related Questions