Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.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
Ajax 是否可以将GWT-RPC调用发送到另一台服务器?_Ajax_Gwt_Service_Gwt Rpc_Cross Domain Policy - Fatal编程技术网

Ajax 是否可以将GWT-RPC调用发送到另一台服务器?

Ajax 是否可以将GWT-RPC调用发送到另一台服务器?,ajax,gwt,service,gwt-rpc,cross-domain-policy,Ajax,Gwt,Service,Gwt Rpc,Cross Domain Policy,假设我有以下GWT服务: @RemoteServiceRelativePath("greet") public interface GreetingService extends RemoteService { String greetServer(String name) throws IllegalArgumentException; } 我在myserver1.com上构建和部署客户端代码,但我的servlet位于myserver2.com(例如http://myserver2.

假设我有以下GWT服务:

@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
    String greetServer(String name) throws IllegalArgumentException;
}
我在
myserver1.com
上构建和部署客户端代码,但我的servlet位于
myserver2.com
(例如
http://myserver2.com/gwt-module-base/greet
)&server1允许服务器2的跨域资源共享。

现在,问题是:我如何将gwt rpc调用发送到myserver2.com而不是myserver1.com?

您只需要在myserver2.com中启用。不久前,我为gwtquery文档编写了一个过滤器。它也适用于RPC和RF

[已编辑]

您必须以以下方式配置服务传输:

GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
((ServiceDefTarget)greetingService).setServiceEntryPoint("myserver2.com/greet");
greetingService.greetServer(....)

我想您误解了我的问题,我的意思是如何告诉GWT将请求发送到server2而不是server1。不管怎样,我找到了解决办法!创建代理对象时可以执行此操作:
GreetingServiceAsync proxy=GWT.create(GreetingService.class);((ServiceDefTarget)代理)。setServiceEntryPoint(“http://myserver2.com/gwt-module-base/greet");
在setServiceEntryPoint参数中,使用GWT.getHostPageBaseURL()作为服务器url前缀,例如GWT.getHostPageBaseURL()+“GWT模块-‌​基地/问候”。感谢您对CORSFilter的实施!很好!