Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT RPC. Share RPC service bwtween two modules

Tags:

java

gwt

I haven an application with 2 GWT-modules (.gwt.xml). I want to share between them one RPC service. But modules have different names, so first module calls RPC service from

FIRSTModuleName/relativepath (and it works)

but second module try to call it from

SECONDModuleName/relativepath (it doesn't work, because path is incorrect).

like image 418
WelcomeTo Avatar asked Feb 19 '23 06:02

WelcomeTo


2 Answers

You can either map your RemoteserviceServlet to both URLs (by far the simplest solution), or you can change your client-side code to make both modules call the same URL.

For the latter, don't use @RemoteServiceRelativePath but instead cast your service async to ServiceDefTarget and call setServiceEntryPoint with the URL you want to use (@RemoteServiceRelativePath is only a shortcut to have setServiceEntryPoint called automatically with GWT.getModuleBaseURL() + relativePath).
I believe you could also use a ../-style URL in your @RemoteServiceRelativePath.

like image 55
Thomas Broyer Avatar answered Feb 28 '23 05:02

Thomas Broyer


And for production don't forget to added a second servlet mapping entry to the web.xml. You can have a servlet listening to as many URLs as you like.

like image 40
Adrian B. Avatar answered Feb 28 '23 05:02

Adrian B.