Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT RPC interface issue

Tags:

rpc

gwt

I have doubt on the below code..

@RemoteServiceRelativePath("stockPrices")
public interface StockPriceService extends RemoteService {

  StockPrice[] getPrices(String[] symbols);
}

Could any one explain me what is the use of @RemoteServiceRelativePath("stockPrices") and what name we need to give in "stockPrices" .. is it mandatory??

thanks in advance!!!

like image 795
Delli Kilari Avatar asked Jul 08 '11 07:07

Delli Kilari


1 Answers

Check out documentation for RemoteServiceRelativePath annotation, it explains pretty well what this annotation does. In your case, your service must be located at GWT.getModuleBaseURL() + "stockPrices" ... that means that if your GWT app is at /mygwtapp, then your service must be at /mygwtapp/stockPrices. It's up to you to install some service at this URL, usually by defining servlet implementing the service interface.

You can use any other path instead of "stockPrices", just make sure there is real service behind this path on the server.

Your remote services need some remote path (entry point), either by using @RemoteServiceRelativePath annotation, or by setting it through ServiceDefTarget interface. If service has no entry point, it cannot be called. (Remember: this path is URL on the server)

For example, instead of using @RemoteServiceRelativePath, you can define your service without this annotation, and then when you instantiate async service proxy, you explicitly set path:

StockPriceServiceAsync stockService = GWT.create(StockPriceService.class);
((ServiceDefTarget) stockService).setServiceEntryPoint("/services/stock.service");
like image 185
Peter Štibraný Avatar answered Nov 15 '22 12:11

Peter Štibraný