Creating an Asynchronous HTTP Message Using the GWT Client

I work in a GWT-based project and I use it only to create RPC requests. I tried to create a new project and make a Cross Site request with the GWT client using RequestBuilder, but I could not get it to work.

I am not very good at GWT. So please, can someone tell me how to create a new project and its settings together with the code for creating cross-site requests from the GWT Client (completely removing RPC calls) ..?

I went through google and stackoverflow, but this has nothing to do. It will be really useful for everyone I hope.

+2
source share
2 answers

We can fulfill Cross Site requests by setting "Access Control Allow Origin http://myexample.com " in the response headers. This will make access available to the browser. More information https://developer.mozilla.org/en/http_access_control

+3
source

If you intend to support only browsers that support CORS (which, you will notice, excludes IE, at least until IE10 is released), then you can simply use RequestBuilder or GWT-RPC, as always.
If you ever use custom request headers, the server will need to allow the client application to cross-start these requests by sending the appropriate Access-Control-Allow-Origin header in response to OPTIONS requests (known as preflight requests in CORS).

If you want / need IE support and you need to make a POST request, then you have no choice but to use the FormPanel and use some trick to pass the response to the client (the easiest is to redirect to a page with the same origin as the application GWT, passing the result in the query string).

If you can do GET instead of POST s, then you can use JsonpRequestBuilder (and, of course, adapt your server code to respond to JavaScript)

+4
source

All Articles