GWT RPC interface problem

I have a question about the code below..

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

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

Can anyone explain the purpose of @RemoteServiceRelativePath(“stockPrices”) What is it and what name do we need to give in “stockPrices”… is it mandatory?

Thanks in advance! ! !

Check the documentation for RemoteServiceRelativePath annotation, it explains the role of this annotation well. In your In this case, your service must be located at GWT.getModuleBaseURL() “stockPrices”… This means that if your GWT application is located at /mygwtapp, then your service must be located at /mygwtapp/stockPrices. You can define a servlet that implements the service interface Come install some services on this URL.

You can use any other path instead of “stockPrices”, just make sure that there are real services behind this path on the server.

< p>Your remote service needs some remote path (entry point), you can use the @RemoteServiceRelativePath annotation, or you can set it to ServiceDefTarget interface. If the service does not have an entry point, you cannot call it. (Remember: this path is the server URL above)

For example, instead of using @RemoteServiceRelativePath, you can define a service without this annotation, and then explicitly set the path when instantiating the asynchronous service proxy:

< p>

StockPriceServiceAsync stockService = GWT.create(StockPriceService.class);
((ServiceDefTarget) stockService).setServiceEntryPoint("/services/stock.service");

I have a question about the code below..

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

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

Anyone can explain @Re What is the purpose of moteServiceRelativePath(“stockPrices”) and what name do we need to give in “stockPrices”… is it mandatory?

Thanks in advance! ! !

Check out the documentation for RemoteServiceRelativePath annotation, it explains very well what this annotation does. In your case, your service must be located at GWT.getModuleBaseURL( ) “StockPrices”… This means that if your GWT application is located at /mygwtapp, then your service must be located at /mygwtapp/stockPrices. You can install certain services on this URL by defining a servlet that implements the service interface.

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

Your remote service needs some remote path (entry Point), you can use the @RemoteServiceRelativePath annotation, or you can set it to the ServiceDefTarget interface. If the service has no entry point, you cannot call it. (Remember: this path is the URL on the server)

For example , Instead of using @RemoteServiceRelativePath, you can define the service without this annotation, and then explicitly set the path when instantiating the asynchronous service proxy:

StockPriceServiceAsync stockService = GWT.create(StockPriceService.class);
((ServiceDefTarget) stockService).setServiceEntryPoint("/services/stock.service");

Leave a Comment

Your email address will not be published.