GWT:在另一个模块内调用RPC服务 [英] GWT: Calling RPC Service inside another module

查看:120
本文介绍了GWT:在另一个模块内调用RPC服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模块B,它继承了模块A.当我从A内部调用RPC Services时,它们工作正常。但是,当我从B中的A调用服务时,RPC调用总是失败。我缺少什么?



感谢您提供任何帮助。 p>我在这里找到了我的问题的答案: http://blog.cloudglow.com/2010/03/making-gwt-rpc-endpoint-independent-of.html



默认GWT RPC服务(Servlet)端点是@RemoteServiceRelativePath(some_name),它在客户端的运行时解析为/ module_base / some_name。这种方法的问题是您的RPC端点现在绑定到GWT模块。虽然这在某些情况下可能没有问题,但这不符合我们的情况。我们最终创建了一个RPC服务工厂类,它将创建服务端点的静态实例并为其添加正确的端点;像这样:

  public class ServicesFactory 
{
public static final RPCServiceAsync RPCService = GWT.create( RPCService.class); (ServiceDefTarget)RPCService).setServiceEntryPoint(GWT.getHostPageBaseURL()+ RPCService.END_POINT);

static
{

}
}


I have a module B, which inherits module A. When I call RPC Services from A inside A, they work ok. But when I call the services from A in B, the RPC invocations always fail. Am I missing something?

Thanks in advance for any help.

解决方案

I've found the answer for my question here: http://blog.cloudglow.com/2010/03/making-gwt-rpc-endpoint-independent-of.html

The default GWT RPC service (Servlet) endpoint is @RemoteServiceRelativePath("some_name"), which resolves to /module_base/some_name at runtime on the client. The issue with this approach is that your RPC endpoint is now tied to GWT Module. While this may be fine for some cases, it was not for our situation. Hence this post.

We ended up creating a RPC services factory class that would create a static instance of the service endpoint and also seed it with the right endpoint; something like this:

public class ServicesFactory
{
public static final RPCServiceAsync RPCService = GWT.create(RPCService.class);

static
{
((ServiceDefTarget) RPCService).setServiceEntryPoint(GWT.getHostPageBaseURL() + RPCService.END_POINT);
}
}

这篇关于GWT:在另一个模块内调用RPC服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆