直接从 Java 调用 GWT RPC 服务 [英] Invoke a GWT RPC service from Java directly

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

问题描述

是否有一种简单的方法可以直接从 Java 代码调用 GWT RPC 服务端点?我的意思是真正的 Java 代码,而不是编译成 javascript 的 Java 代码.

Is there an easy way to invoke a GWT RPC service endpoint directly from Java code? I mean real Java code, not Java code compiled down into javascript.

我之所以这么问是因为我们想针对 GWT RPC 接口运行性能基准/压力测试.我想用 Java 编写测试工具并在 JVM 中运行它(而不是在浏览器中运行的 javascript).

I ask because we want to run performance benchmarks/stress tests against a GWT RPC interface. I would like to write the test harness in Java and run it in a JVM (as opposed to javascript running in a browser).

我认为必须有一种方法可以做到这一点,因为我认为 GWT 托管模式需要这样的功能.但是,我真的在 GWT 运行时中找不到任何代码来演示如何干净地执行此操作.我查看了 com.google.gwt.user.client.rpc 包,但里面的东西似乎使用了 JSNI,这显然不能被纯 Java 使用.

I figure there must be a way to do this because I assume GWT Hosted mode requires such functionality. However, I can't really find any code in the GWT runtime that demonstrates how to cleanly do this. I've looked at the com.google.gwt.user.client.rpc package but the stuff in there seems to use JSNI which obviously wouldn't be usable by pure Java.

推荐答案

GWT SyncProxy 允许您从纯 Java(而非 JSNI)代码访问 GWT RPC 服务(例如方法).因此,您可以使用它来测试您的 RPC 接口.

GWT SyncProxy allows you to access GWT RPC services (e.g methods) from pure Java (not JSNI) code. Thus you can use it to test your RPC interface.

参见 http://www.gdevelop.com/w/blog/2010/01/10/testing-gwt-rpc-services/ 了解详情.

这篇关于直接从 Java 调用 GWT RPC 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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