Ashok
Ashok

Reputation: 1952

GWT Async to URL

I'm using GWT to develop a web app. I'm currently using AJAX calls to retrieve values from the server. I have following queries regarding to AJAX calls:

Assume: I have an app, name of which is: "Application" and the entry point class is: "entry.java"

I know: the application could be invoked as: http://localhost:8080/Application/entry.html

1. I would like to know what what is the output URL given by gwt.getmodulebaseURL()?

Assume: In the same application I have a service called "ServerValuesService" and its corresponding Async. I have corresponding serviceImpl, which has a method called List < String >search(String) at the server side.

I could retrieve the values from the server as well. However,

2. I would like to know what would be the direct URL to access this service? For Instance, I need to obtain the list of values, by just giving a URL (passing value for the String). i.e. I need to access the method search(String) and retrieve the list just by typing a url such as:

http://localhost:8080/Application/entry/serverValuesService?string="hello"

I'm sure the above URL is wrong. I need to know exact conversion between URL and the corresponding service. Is this possible at all?

Thanks in advance!

Upvotes: 0

Views: 1068

Answers (2)

Tahir Akhtar
Tahir Akhtar

Reputation: 11625

Assume: I have an app, name of which is: "Application" and the entry point class is: "entry.java"

I know: the application could be invoked as: http://localhost:8080/Application/entry.html

The url http://localhost:8080/Application/entry.html is called host page url. In this html page you load your GWT module using a script tag:

<!-- This script tag is what actually loads the GWT module.  The -->
<!-- 'nocache.js' file (also called a "selection script") is     -->
<!-- produced by the GWT compiler in the module output directory -->
<!-- or generated automatically in hosted mode.                  -->
<script language="javascript" src="calendar/calendar.nocache.js"></script>

So if you put above example in your entry.html, the module will be loaded from http://localhost:8080/Application/calendar/calendar.nocache.js making http://localhost:8080/Application/calendar/ your module base url.

I would like to know what would be the direct URL to access this service? For Instance, I need to obtain the list of values, by just giving a URL (passing value for the String). i.e. I need to access the method search(String) and retrieve the list just by typing a url

GWT RPC use a custom serialization format to encode requests to the RPC Service on server. The RPC service is implemented as a subclass of RemoteServiceServlet on the server. The RemoteServiceServlet handles the http POST requests, de-serializing the request from client and invvoking appropriate service method of sub-class.

So for directly accessing the service you'll need: 1. The service URL 2. Request payload encoded in GWT's custom serialization format 3. Ability to HTTP POST the payload to the Service URL

1 and 3 are easy to acquire. You already know the URL at which your service is mapped in web.xml. And you can do post from any http client or browser plugins like this. The hard-part would be to generate request payload in GWT's custom serialization format. For simple cases, you can generate a request from your application and capture the raw payload from Firebug, Fiddler or similar tool and simply replay it using your http client.

Upvotes: 1

pistolPanties
pistolPanties

Reputation: 1890

1) In your case it will give you http://localhost:8080/Application . Application is your modulename.

2) These services are actually HttpServlets and their URL's are defined in the web.xml file. But Google uses POST method to send your variables and takes care of serialization for you, what you are trying to do is send it via GET method which is as far as I know not implemented by Google RemoteServiceServlet.So I would say no its not possible unless you extend these services to work with GET methods yourself but I don't know if that is possible.

Upvotes: 1

Related Questions