tags:

views:

222

answers:

2

Try to use GWT RPC in our application. Our application serve static content and dynamic content with different base url. for example, url to foo.jsp may have http//localhost/context/foo.jsp served by websphere, for img/js inside that jsp, we will have url like http//localhost/uistatic/foo.js, served by iis, and GWT generated code will be included as http//localhost/uistatic/......

Now, when using GWT RPC, the modulebaseurl GWT default will actually point to http//localhost/uistatic/ which is not correct one, for calling rpc service, we can override ServiceEntryPoint by doing following (using HostPageBaseURL):

serviceDef.setServiceEntryPoint(GWT.getHostPageBaseURL() + GWT.getModuleName() + ......);

However, to use serializable DTO for rpc call, GWT load serialization policy file by using modulebaseurl which again is wrong (http// localhost/uistatic/), anyone know how to override it, or any other suggestion are welcome.

Thx

A: 

From http://code.google.com/webtoolkit/doc/1.6/FAQ_Server.html#Does_the_GWT_RPC_system_support_the_use_of_java.io.Serializable

RPC now generates a serialization policy file during GWT compilation. The serialization policy file contains a whitelist of allowed types which may be serialized. Its name is a strong hash name followed by .gwt.rpc. In order to enable support for java.io.Serializable, the types that your application will send over the wire must be included in the serialization policy whitelist. Also, the serialization policy file must be deployed to your web server as a public resource, accessible from a RemoteServiceServlet via ServletContext.getResource(). If it is not deployed properly, RPC will run in 1.3.3 compatibility mode and refuse to serialize types implementing java.io.Serializable.

Perhaps you can override/intercept the call to getResource.

Also Check this out...http://code.google.com/webtoolkit/doc/1.6/FAQ_Server.html#What_is_the_Same_Origin_Policy,_and_how_does_it_affect_GWT?

Michael

Michael Dausmann
A: 

You can override doGetSerializationPolicy in your RemoteServiceServlets to control how the policy file is loaded.

Isaac Truett