Re: RPC for Xsite communication
Ok I think I got it! :]
Looking to the classes around RemoteService I found this in the javadoc of ServiceDefTarget:
/** |
* An interface implemented by client-side RPC proxy objects. Cast the object |
* returned from {@link com.google.gwt.core.client.GWT#create(Class)} on a |
* {@link RemoteService} to this interface to initialize the target URL for the |
* remote service. |
*/ |
And it let you change the complete URL of the servlet with setServiceEntryPoint(). I tried with a servlet deployed in a different port and I got the SOP error from the browser, then after adding it to the whitelist it worked like a charm :)
Thank goodness it was in this way because otherwise I would have to parse and serialize all manually.
On Monday, July 15, 2013 2:56:12 AM UTC-5, Thomas Broyer wrote:
On Monday, July 15, 2013 2:44:38 AM UTC+2, carrizo wrote:If I understand it correctly the RPC framework is intended only for same-origin communication and the alternatives to workaround SOP are: using RequestBuilder (XmlHttpRequest) directly or JsonpRequestBuilder (a <script> tag).The downside with those alternatives is that you lose the automatic serialization magic of the rpc framework which is very sad because these days you can whitelist servers to make XmlHttpRequests safely.So before going to work directly with RequestBuilder I would like to know if there is a way to enable it for xsite use. I'm assuming that the implementation just uses RequestBuilder behind the scenes and that it would be easy to change it.I don't think CORS is a problem with GWT-RPC. Did you try it?Notes:
- GWT-RPC is built on top of RequestBuilder, so whatever you can do with RequestBuilder you can do it with GWT-RPC too (note: you can make your async methods return a Request or RequestBuilder instead of 'void'; Request allows you to cancel an ongoing call while RequestBuilder allows you to tweak the request before send()ing it)
- Not all browsers support CORS there days unfortunately (IE, you guessed it; only IE10+ supports it: http://caniuse.com/cors)
- If you cannot use CORS, you still have the option to use a "proxy" on the same origin as your HTML host page. A while ago I posted the code of a servlet in https://code.google.com/p/
google-web-toolkit/issues/ detail?id=3131
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home