Hello All, Recently I encountered the need to perform some cross domain RPC without using the server for relaying it. I had some good reads on that [1]. This weekend I think I came up with an approach that does without noticeable performance impacts. It use the window.name tranport [2] technique.
The scenario: 1. Setup a custom RPCRequestBuilder which intercepts RPC calls 2. Setup a form and an iframe that points to the target domain 3. When the RPCRequestBuilder is fired, get the RPC payload (setData ()), feed the form and submit the form 4. Implementation detail: I could not get the form submission to contain the encoding headers required by the server side RPC implementation, so I'm faking them with a stub servlet filter infront of the RPC servlet. 5. Have the servlet process the request and return the RPC payload 6. The servlet now gets the payload and changes it into the following HTML: <body> <script>window.name='your rpc payload here'</script> </body> 7. On the browser side, the target frame setup in 2 is polled until window.name changes. The payload is then extracted and returned from the RPC request builder There are some problems here which should be solvable though: - It's said that window.name has some length limitations. So there would be a need for some sophisticated inter-frame communication that forwards chunks. - Error handling might get more complicated - I've not been able to set the request headers expected by the server side RPC implementation, hence I'm setting them on the server side via a pre-pended filter - I've not been able to setup the form and frame required by step 2 via DOM manipulations; though I'd probably need to investigate that further, I could so far get it to work only when both the form and iframe were already existing in the HTML. - Tested on FF 3.5 only. Currently I'm trying to wrap this up and make it more user friendly and get it into some future release of the SL. [1] http://groups.google.com/group/Google-Web-Toolkit-Contributors/browse_thread/thread/94c18c4ec158070c [2] http://www.sitepen.com/blog/2008/07/22/windowname-transport/
-- http://groups.google.com/group/Google-Web-Toolkit-Contributors
