使用DWR,可以将多个服务调用组合到一个HTTP请求中:
dwr批处理功能
此功能对于减少ajax应用程序的延迟非常有用.有没有办法用GWT/GWT-RPC做类似的事情?
谢谢你的帮助
我试图找出如何使用GWT RPC将域对象从服务器端发送到客户端.我编写了一个非常简单的用例,它表示我(和其他人)需要能够做的事情,但目前无法开始工作.
我已经浏览了文档,教程和论坛,但他们要么显示字符串被传递,要么提供解释(当我将它应用于此时)仍然无效.
希望有人可以向我和其他人解释为什么这些代码不起作用以及如何使其工作.
谢谢.
以下是错误消息.
13:12:54.328 [DEBUG] [org.redboffin.worldhug.Test] Validating newly compiled units
13:12:54.328 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestService.java'
13:12:54.343 [ERROR] [org.redboffin.worldhug.Test] Line 14: No source code is available for type org.redboffin.worldhug.server.test.TestObject; did you forget to inherit a required module?
13:12:54.515 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestServiceAsync.java'
13:12:54.515 [ERROR] [org.redboffin.worldhug.Test] Line 12: No source code is available for type org.redboffin.worldhug.server.test.TestObject; did you forget to inherit a required module?
13:12:55.953 [ERROR] [org.redboffin.worldhug.Test] Errors in 'file:/C:/Documents%20and%20Settings/Darren/workspace/WorldHug/src/org/redboffin/worldhug/client/test/TestView.java'
13:12:55.968 [ERROR] [org.redboffin.worldhug.Test] Line 42: No source …Run Code Online (Sandbox Code Playgroud) 我目前正在使用GWT创建一个站点,在AppEngine上托管.我正在制作我正在制作的自己的登录信息(我知道谷歌提供了一些GWT,但我需要自己的登录系统),而且我一直试图找出会议已经有一段时间了.我找到了一些教程,其中一个我正在阅读的网站是http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
那里有一节"如何记住登录".我知道如何通过RPC调用获取会话ID并将其存储在cookie中的客户端上.我不明白的是,最终在一天左右后,用户回来了,我应该从cookie中获取会话ID并将其发送回服务器.为了安全地评估会话ID是否合法,我应该在服务器上做什么,并提取有关用户的所有必要信息?
其他问题:1.什么会使会话ID发生变化?2.如果用户在笔记本电脑上,并且用户去了其他地方,该怎么办?他是否仍然可以安全地重新登录,而无需再次输入他的登录名和密码?
谢谢!
〜斯科特
升级到GWT 2.3后,我的一些RPC服务不再工作,并且失败并显示"响应无法反序列化".似乎发生在返回使用使用@Temporal(TemporalType.TIMESTAMP)注释的Date对象的对象的服务.我使用Gilead 1.3.2和Hibernate 3.6,我对GWT 2.2没有任何问题.知道会发生什么,或者如何开始调试?
这是堆栈跟踪:
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: The response could not be deserialized
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:221)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java: 287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214)
at sun.reflect.GeneratedMethodAccessor27.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:680)
Caused by: com.google.gwt.user.client.rpc.SerializationException: java.sql.Timestamp/1769758459
Caused by: com.google.gwt.user.client.rpc.SerializationException: …Run Code Online (Sandbox Code Playgroud) 在托管模式下运行我的GWT应用程序(gwt 2.0.4)时,调用在远程Tomcat上运行的RPC方法,我得到GWT序列化异常:
INFO: GwtRpcEventSrvc: ERROR: The serialization policy file '/84EC7BA65AF8175BAA99B47877FDE163.gwt.rpc' was not found; did you forget to include it in this deployment?
SEVERE: GwtRpcEventSrvc: WARNING: Failed to get the SerializationPolicy '84EC7BA65AF8175BAA99B47877FDE163' for module 'http://host:19980/MYAPP/'; a legacy, 1.3.3 compatible, serialization policy will be used. Youmay experience SerializationExceptions as a result.
SEVERE: Exception while dispatching incoming RPC call
Throwable occurred: com.google.gwt.user.client.rpc.SerializationException: java.lang.reflect.InvocationTargetException
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeWithCustomSerializer(ServerSerializationStreamWriter.java:760)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeImpl(ServerSerializationStreamWriter.java:723)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:612)
.at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:129)
.at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
...
Caused by: com.google.gwt.user.client.rpc.SerializationException: Type 'com.mypackage.data.MyData' was not assignable to …Run Code Online (Sandbox Code Playgroud) 是否可以重新发送RequestFactory传输?我想做相同的事情:如何在使用RequestFactory时重新发送GWT RPC请求.从先前的请求重新发送相同的有效负载相当简单,但我还需要调用相同的方法.这是我的RequestTransport类,我希望在处理用户登录凭据的请求之后,只需"重新启动"原始请求:
package org.greatlogic.rfexample2.client;
import com.google.gwt.http.client.Request;
import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.Response;
import com.google.web.bindery.requestfactory.gwt.client.DefaultRequestTransport;
/**
* Every request factory transmission will pass through the single instance of this class. This can
* be used to ensure that when a response is received any global conditions (e.g., the user is no
* longer logged in) can be handled in a consistent manner.
*/
public class RFERequestTransport extends DefaultRequestTransport {
//--------------------------------------------------------------------------------------------------
private IClientFactory _clientFactory;
//==================================================================================================
private final class …Run Code Online (Sandbox Code Playgroud) 我的问题是在通过子域访问页面时使用GWT 2.6.1时发生臭名昭着的"StatusCodeException:0"问题.https://sub.site.com/
现在,这种情况相当零星的一个客户使用IE11和我不能重现使用IE11,IE10,IE9还是IE8(不谈论Chrome或Firefox)几个不同的计算机上这一点.
从中访问完全相同的webapp https://site.com/似乎对该客户起作用.
这显然让我得出结论,我在同源策略方面遇到了问题.
但奇怪的是,我的webapp的设计方式是没有跨域或跨子域请求.这同样适用于无交叉协议以及无交叉端口的请求.换句话说,在这种情况下不违反同源政策.作为对此的确认,我可以提供以下证据:
在客户现场我已经看到了如何重现:客户开始使用应用程序,一切正常 - 所有请求都正常返回响应.然后,经过几分钟的工作,同一页面上的完全相同的请求(没有重新加载)开始失败,并显示StatusCodeException:0.
基本上,无论是https://sub.site.com和https://site.com指向同一个IP,并有只有一个Tomcat的web应用程序正是服务于相同的资源两个https://sub.site.com和https://site.com.
另一个证明是单个GWT模块本身的代码库:在那里我只使用一个服务的一个实例DashboardService:
public class DashboardModule extends EntryPoint implements IDashboardModule {
private final DashboardServiceAsync dashboardService = createDashboardService();
@Override …Run Code Online (Sandbox Code Playgroud) 现在,我的许多应用程序使用GWT-RPC从GWT RemoteService检索POJO,后者又调用Web服务(SOAP)来获取数据.我正在评估Flex,并没有真正看到任何真正类似于这个简单架构的东西.我可能错过了什么?
我有RPC服务,返回从Event(抽象)扩展的GameEvent类型的对象.当我在客户端获取对象时,从Event(eventId,copyEventId,gameTimeGMT)继承的所有属性都设置为,null而在服务器端,这些属性具有值.
public class GameEvent extends Event implements IsSerializable {
private String homeTeam;
private String awayTeam;
public GameEvent() {
}
}
// Annotation are from the twig-persist framework which should not
// impact the serialization process.
public abstract class Event implements IsSerializable {
@Key
protected String eventId;
@Index
protected String copyEventId;
protected Date gameTimeGMT;
protected Event() {
}
}
Run Code Online (Sandbox Code Playgroud)
更新:我使用gwt-platform框架(MVP实现).这是对服务客户端的调用.在result.getGE()返回GameEvent对象,但与null属性.
dispatcher.execute(
new GetFormattedEventAction(
id),
new AsyncCallback<GetFormattedEventResult>() {
@Override
public void onFailure(Throwable caught) {
caught.printStackTrace();
} …Run Code Online (Sandbox Code Playgroud) 我对Android中GWT-RequestFactory的使用有疑问.为起点我使用的代码从"创建连接Android的一个项目的AppEngine" -向导(相关信息:http://code.google.com/intl/de-DE/eclipse/docs/appengine_connected_android.html)和它工作得很好.
但现在在我的情况下,我希望扩展此应用程序以使用带有SQLite的本地ContentProvider和带有SyncAdapter的SyncService,使用RequestFactory将ContentProvider中的数据同步到AppEngine.现在我的问题如下:我可以打电话
MyRequestFactory requestFactory = Util.getRequestFactory(mContext, MyRequestFactory.class);
Run Code Online (Sandbox Code Playgroud)
在我想要的任何活动中,将收到MyRequestFactory的实例.(注:是的Util由向导创建的类.)但是,如果我试图让从我SyncAdapter相同的呼叫,我会得到了java.lang.RuntimeException:本RequestFactory ValidationTool必须为com.hotool.client运行. MyRequestFactory RequestFactory类型".
也许您的信息:Util.getRequestFacory方法如下所示:
/**
* Creates and returns an initialized {@link RequestFactory} of the given
* type.
*/
public static <T extends RequestFactory> T getRequestFactory(
Context context, Class<T> factoryClass) {
T requestFactory = RequestFactorySource.create(factoryClass);
SharedPreferences prefs = getSharedPreferences(context);
String authCookie = prefs.getString(Util.AUTH_COOKIE, null);
String uriString = Util.getBaseUrl(context) + RF_METHOD;
URI uri;
try {
uri = new URI(uriString);
} catch (URISyntaxException e) {
Log.w(TAG, "Bad URI: " + uriString, …Run Code Online (Sandbox Code Playgroud)