MayoMan
MayoMan

Reputation: 4917

Calling GWT RPC service

I have been going through the google tutorial ( which I find very good ) at https://developers.google.com/web-toolkit/doc/latest/tutorial/RPC

I have the service up and running on my local server and my JavaScript client can call it fine. OK so far. Now, what I want to do is deploy the service on a remote server JoeSoapHost:8080
How do I now tell my client where to send it's requests? I can't see any server/url being created in my RPC call. It just works by magic but now I want to get under the bonnet and start breaking it.

[Edit} This is the Interface my client uses to know what service on the Server is to be called. I know that my Web.xml web descriptor must have a url that matches this. It has this because my server is invoked ok. Problem is, if I now decide to deploy my server elsewhere how do I tell my client what server/domain name to use?

@RemoteServiceRelativePath("stockPrices")
public interface StockPriceService extends RemoteService 
{
    StockPrice[] getPrices(String[] symbols);
}

What I want to achieve first is have a simple GWT client calling into an RPC service. I have this working but only when the server is localhost. Next step, I deploy my app to the Google App Engine. What must I change now because my RPC service in my JavaScript is not being called when I deploy my app to http://stockwatcherjf.appspot.com/StockWatcher.html

Upvotes: 0

Views: 1063

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64551

@RemoteServiceRelativePath gives the path of the servlet relative to the GWT.getModuleBaseURL() (which is more or less the URL of the *.nocache.js script); it doesn't "just work by magic".

If you deploy your services on a different server than the one serving your client code, then you'll likely hit the Same Origin Policy. CORS can help here, but you'll lose compatibility with IE (up to IE9 included). You'd better stick serving everything from the same origin.

Upvotes: 0

appbootup
appbootup

Reputation: 9537

1) Brian Slesinsky excellent document on RPC - https://docs.google.com/document/d/1eG0YocsYYbNAtivkLtcaiEE5IOF5u4LUol8-LL0TIKU/edit#heading=h.amx1ddpv5q4m

2) @RemoteServiceRelativePath("stockPrices") allows GWT code to determine relative to your host/server/domain i.e http//mydomain.com/gwtapp/stockPrices

3) You can search GOOGle IO Sessions from 2009 - 2012 for some more in depth stuff on GWT RPC usage.

Upvotes: 0

Related Questions