文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > Communicate whith a service
侵权投诉

Communicate whith a service

Communicate whith a service

1. 创建一个接口XXX继承RemoteService接口

2. 再创建一个借口继承RemoteServiceServlet并实现XXX

3. 创建一个异步接口,名字为服务接口名字再加上Async,(即XXXAsync),两个

接口放在同一个包下,定义异步兄弟方法

4. 确定客户端代码可以通过在web.xml中映射的SERVLET的URL进行服务调用。

例子

假定你想调用一个服务接口中的方法,如下定义

public interface MyEmailService extends RemoteService { void emptyMyInbox(String username, String password); }

它的异步对应接口会如下所示:

public interface MyEmailServiceAsync {

void emptyMyInbox(String username, String password, AsyncCallback callback);

}

客户端调用如下所示:

public void menuCommandEmptyInbox() {

// (1) Create the client proxy. Note that although you are creating the

// service interface proper, you cast the result to the asynchronous

// version of

// the interface. The cast is always safe because the generated proxy

// implements the asynchronous interface automatically. //

MyEmailServiceAsync emailService = (MyEmailServiceAsync) GWT.create(MyEmailService.class);

// (2) Specify the URL at which our service implementation is running.

// Note that the target URL must reside on the same domain and port from

// which the host page was served.

//

第1页

你可能喜欢

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email