From what I understand the Spark Framework for Java makes it very easy to run a restful server that accepts, POST, GET, etc..
Is there an easy way to send a POST out using the spark library?
The idea is to handle requests asynchronously and to respond via a callback. That callback requires an asynchronous post to come from my application to another web server.
You'll have to add another library to act as the rest client. Spark is intended to be a rest server.
Related
I am working on an android application(backend coding) like uber, currently we are using websockets for communicating with server.
Will it be better to use java sockets instead of websockets?
At server-side:
I am using JAVA,RESTful web service for receiving the request,like login,logout,change password,etc and saving the request to DB.
Using Websockets (after receiving the above request) for other logic (main logic like finding nearest agent, sending customer request to agent, sending agent response to customer using their sessions).
If YES, what will be the reasons for sockets over websockets here?
I need to create an async web service using jax-ws and I need configure it in a Oracle Service Bus 12c.
will you have some tutorials that explain step by step how to achieve it?
What are the best practices?
If you need to use Oracle Service Bus as an intermediate layer for an asynchronous backend service, you need to create two synchronous proxy services:
First for sending the request to the service and providing the synchronous reponse back to consumer.
Second for sending the asynchronous response to the original consumer.
Service Bus does not support asynchronous (long-running) services. The drawback of this solution is that these two services are completely separate.
I would prefer using BPEL for this scenario (which is also part of SOA Suite), if possible. You can create an asynchronous BPEL process which will cover the whole asynchronous communication by a single SOA composite. You can match the request and asynchronous response and easily indicate which requests got their responses. You can also utilize WS-Addressing.
Is there a way today within the Jersey API to decouple a client request from the response and asynchronously send back a response?
I guess I am looking for an alternative to the startAsync() method of a HTTPRequest object within Jersey - havent seen something of that sort yet, although I have come across the Atmosphere project - which looks somewhat promising, but are there any other options?
If you are looking for a client-side async api, look at AsyncWebResource in Jersey client API.
If you mean suspending the request processing on the server side, we are adding that only in Jersey 2.0.
I am using GWT RPC to communicate between the client and the servlet, but from that same servlet, I need to send XML data through a POST HTTP Request to an External web service.
Basically, I send it some XML data, the Web Service processes it and returns some other XML Data that I will be using.
I tried using com.google.gwt.http.client.RequestBuilder but I was getting an Exception error (java.lang.UnsatisfiedLinkError).
From what I've read, this is due because that class is a CLIENT class, and therefore cannot be used in the servlet (server-side).
What else can I use to build POST HTTP Requests?
Thanks in advance.
(Since the servlet is some java bytecode running, instead of java translated to Javascript on the client, I can basically use Java classes from the JRE/JDK)
Do NOT use any GWT specific classes in your servlet code!
why narrow the wide thing!
There are variety of APIs you can use to send HTTP requests to external servers..
If you don't like to use any external libs, then use java.net.URLConnection
it is simple to use..
Or even you can use the most simpler one, Apache HTTPClient
We are seeing Spring in school right now but we don't have the time to wait till the end of the semester to start developing an application. We continue using an app we made last year, and are writing the service layer right now.
The problem is our "client" wants to have a desktop client and a webpart, which used the same dtatabase. This would be no problem if we hook up a server that can handle RMI. So basically we want to be able to retrieve/send data to the server that runs our service layer, and use the objects on the client side as well.
I have no idea where to start digging in Spring to figure out how to do this, so some help would be appreciated.
PS: At this point I do not need MVC yet. MVC is handled from within the desktop app where we have views and controllers.The model is the same from the one on the service layer. How do we use the same model without copying it?
Check out spring remoting: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html
It's easy to expose your spring beans remotely, using a variety of protocols.
You might want to take a look at the REST paradigms. With this in mind you could have a web server running your server part of the application and communicating with clients through the HTTP protocol. A simple client could be a webpage in the browser which gets the corresponding HTML pages from the server, or a Swing client which communicates over JSON with the server.
The server can implement different methods for JSON or HTML communication and the server can decide what implementation to use by looking at the Accept Header of the Request objects sent to it, that's what they call Content Negotiation
JSR-311 is implemented as Project Jersey which is a framework for RESTful webservices. You might want to take a look at that.
hope that helped