How can one get the full HTTP REST request body for a POST
request using Jersey?
In our case the data will be XML. Size would vary from 1K to 1MB.
The docs seem to indicate you should use MessageBodyReader
but I can't see any examples.
Jersey is Sun's production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM.
Jersey annotations are runtime annotations, therefore, runtime reflection will generate the helper classes and artifacts for the resource, and then the collection of classes and artifacts will be built into a web application archive (WAR).
So, yes, you can send a body with GET, and no, it is never useful to do so. This is part of the layered design of HTTP/1.1 that will become clear again once the spec is partitioned (work in progress). Yes, you can send a request body with GET but it should not have any meaning.
Turns out you don't have to do much at all.
See below - the parameter x
will contain the full HTTP body (which is XML in our case).
@POST public Response go(String x) throws IOException { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With