OData defines a batch request format for bundling multiple HTTP requests together into a single request. I'm working on a web service that must handle these batch requests.
After parsing the multipart request, I have the binary data for each individual request in the batch. Now I'd like to route each request through the Jersey dispatcher and collect the responses.
How do you get a reference to the Jersey dispatcher? Is there a better way to implement OData batch processing in Jersey?
Related
I am using spring boot framework to generate a soap request to consume the soap service.
Using SOAP-UI/ Postman, I can be able to send the request in xml format as specified in service wsdl.
But, I am generating soap request body my marshalling the java object and sending it through spring application.
Is there any way to see/visualise the intermediate request in XML format in this case ?
I’m looking for a way to find the HTTP version of incoming request in spring webflux netty server
I cannot find any method in ServerWebExchange to get this information.
Spring servlet has some implementation to get it as given in springboot servlet.
Is it any possibility to get it in webflux implementation?
Is there any way to achieve multiple responses from a single request using Spring Boot ? If yes, please provide me a link.
HTTP does not work this way. An HTTP request has exactly one response. Spring Boot will not let you send more than one response, because that would be against the HTTP specification and no HTTP clients would be able to figure out what was going on.
There may be another way to accomplish your underlying goals, but whatever it is, it won't involve sending more than one HTTP response to a single HTTP request.
I'm a Jersey / REST newbie and am trying to write a simple web service. The issue I have is the storage of data between requests.
Servlets can access sessions but I didn't believe Jersey / REST allows this.
I am currently writing this service so that an Android app will make RESTful requests to Tomcat.
Now I am not sure yet of the type of request these will be: should they be URLs with parameters, or simply an XML string? The type of data to be transmitted from the app will include addresses of RSS feeds and keywords and sundry metadata.
The XML responses from the server will again consist of RSS feed addresses, keywords, frequencies of the keywords and other metadata.
The idea at the moment is to use JAXB on both app and server to make up and break down the XML into Java objects.
JSON or GSON are not available alternatives here.
But what about storing data between requests? Is it enough to store all the relevant variables in XML if XML forms the request and response actions, where each request will have an ID number referring to the server's database.
Or is it better to use the session context for servlets via REST?
Apologies if the above sounds vague. I am a Jersey / REST newbie.
While as has been said it is generally recommended your WS calls to be stateless, Jersey does rely on Servlet, so you can inject the HttpServletRequest and get the session from there:
#GET
public String getMethod(#Context HttpServletRequest req) {
HttpSession session= req.getSession(true);
...
You can then configure your web server session storage to memory, cookie, cache, db, or whatever.
REST webservices are based on the HTTP protocol which is a stateless protocol.
In my opinion, saving state in your webservice is not a good idea.
You should use cookies to store user data.
JAX-RS services can either be singletons or per-request objects. A singleton
means that one and only one Java object services HTTP requests. Per-request means
that a Java object is created to process each incoming request and is thrown away at
the end of that request. Per-request also implies statelessness, as no service state is held
between requests.
I coulnd't find any indication in Spring documentation that it support read of files in streaming mode in its object MultipartHttpServletRequest that handle multipart requests.
in similar way that is possible in Apache Commons framework.
is it supported in Spring at all?
Yes, have a look here. Your Spring API is far too old. Also, the Streaming mode has nothing to do with Spring. It is the ability of your servlet container or your server. Most server now support the streaming mode. Servlet will start performing the request as soon as it got the header from your request. You can continue to send out the stream of your request body (e.g. multipart data). However, the parsing can only be performed completely when the request is sent fully. This is the same as Apache Common FileUpload.
Alternatively, you can write a controller using Spring annotation. Spring will inject the ServletRequest if you add that as one of your method controller arugument. After that, you can use Apache FileUpload to do multipart parsing.
You can not do selective parsing since the request must be fully sent to server no matter what. It is the limit of Http. I asked the question a few day ago.