How does the client know which RPC URL to access?

3 views
Skip to first unread message

juli...@googlemail.com

unread,
Oct 19, 2009, 8:01:18 AM10/19/09
to gwt-sl
Hi,

after reading your documentation and example code there's one thing I
couldn't quite figure out: how does the client code know which URL to
access on the server?

For example, in your example at http://g.georgovassilis.googlepages.com/usingthegwtcontroller
you say "In our example the complete URL to the service would be
http://localhost:8080/gw-wl-sl/controller/add.rpc". I can see how you
arrive at this URL by looking at the (server side) configuration, but
how does the client code know? Could you briefly explain the mechanics
of, or should I say the magic behind this?

On a side note, here is a small nitpick: nearly every tarball I
download and unpack (and I have unpacked a LOT of tarballs) will
create a single directory named after the tarball. In nearly every
case I can rely on "tar xzf foo-1.2.3.tar.gz; cd foo-1.2.3" working -
or, more importantly, I can rely on un-tarring not polluting my
current working directory with more than one subdirectory. This
doesn't work for your tarball though. I know that there is a different
convention for zip files, but for tar balls I would suggest to stick
with this unwritten rule.

Thanks again,

Julian

George Georgovassilis

unread,
Oct 19, 2009, 3:50:07 PM10/19/09
to gwt...@googlegroups.com
Hello Julian,

with regard to determining the correct URL, the RPC mechanism is not any
more or any less magic than the rest of HTTP/HTML. When you load an HTML
document from http://somesite/path/document.html and inside that
document you refer to an image as "images/welcome.jpg", then the browser
understands this as a relative URL, so it will take the base path of the
document and resolve the image relative to that:

http://somesite/path/ + images/welcome.jpg

With RPC the same thing happens: the browser loads the GWT javascript
from some URL and will resolve all RPC requests relative to that URL.

Also bare in mind, that the SL is _not_ about the client. It does not
contribute a single byte to client code, it is all about server
configuration. You could run a programme on the browser, shutdown the
server, strip off the SL jar and load an application with plain GWT and
your client would not note the difference.

So, the client just does the usual GWT.create(...) and
ServiceDefTarget.setServiceEntryPoint(url)
Reply all
Reply to author
Forward
0 new messages