Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GWT RPC接口问题_Gwt_Rpc - Fatal编程技术网

GWT RPC接口问题

GWT RPC接口问题,gwt,rpc,Gwt,Rpc,我对下面的代码有疑问 @RemoteServiceRelativePath("stockPrices") public interface StockPriceService extends RemoteService { StockPrice[] getPrices(String[] symbols); } 有谁能解释一下@remoteservicereparativePath(“stockPrices”)的用途,以及我们需要在“stockPrices”中给出什么名称。。它是强制性的吗

我对下面的代码有疑问

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

  StockPrice[] getPrices(String[] symbols);
}
有谁能解释一下
@remoteservicereparativePath(“stockPrices”)
的用途,以及我们需要在“stockPrices”中给出什么名称。。它是强制性的吗

提前感谢

看看,它很好地解释了这个注释的作用。在您的情况下,您的服务必须位于
GWT.getModuleBaseURL()+“stockPrices”
。。。这意味着,如果您的GWT应用程序位于
/mygwtap
,则您的服务必须位于
/mygwtap/stockPrices
。您可以在这个URL上安装一些服务,通常是通过定义servlet实现服务接口

您可以使用任何其他路径而不是
“stockPrices”
,只要确保服务器上此路径后面有真正的服务即可

您的远程服务需要一些远程路径(入口点),可以使用
@RemoteServiceRelativePath
注释,也可以通过设置来实现。如果服务没有入口点,则无法调用它。(请记住:此路径是服务器上的URL)

例如,您可以在不使用此注释的情况下定义服务,而不是使用
@RemoteServiceRelativePath
,然后在实例化异步服务代理时,显式设置路径:

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