如何从 c 或 c++ 调用 gwt rpc servlet使用 libcurl 的客户端?
我有一个带有 GWT 客户端的谷歌应用程序引擎应用程序。大多数服务器功能都可以像往常一样通过正常的 GWT RPC 调用来访问。我正在用 C++ 编写一个数据挖掘应用程序,它需要与 appengine 应用程序进行通信。问题是,实现了太多的 gwt servlet,因此不可能重写服务器代码。
有什么想法吗?
I have a google app engine application with a GWT client. Most server functionality is accessible through normal GWT RPC calls as usual. I am writing a data mining application in C++ which needs to communicate with the appengine application. Problem is, there are just too many gwt servlets implemented so a rewrite of server code is out of the question.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在客户端上使用 java,则可以使用 GWT SyncProxy。虽然该库的主要用例是测试远程 gwt rpc 服务,但它可以有效地用于任何目的。当您使用 C++ 开发客户端时,这可能不适合您。
如果您控制 GWT 应用程序(即您可以重新编译它),您可能可以执行以下操作:
将 RPC 相关函数导出到 javascript。也就是说,您的 GWT 代码的特定函数可以作为普通 Javascript 函数从主机页面内调用。请参阅这篇文章获取教程
使用嵌入式浏览器引擎,如 webkit 并加载您的其中的 GWT 模块脚本。
将导出的 GWT 函数作为普通 java 函数调用。
但事实可能证明这工作量太大,因此您最好重构 servlet,以公开除 RPC 之外的另一个基于 JSON/XML 的接口。
If you were using java on the client you could use GWT SyncProxy. Although main usecase of this library was to test remote gwt rpc service, but it can be effectively used for any purpose. As you are developing your client in C++ this might not be an option for you.
If you control the GWT application (that is you can recompile it), you can probably do something like this:
Export RPC related functions into javascript. That is make specific functions of your GWT code made available to be called as normal Javascript functions from within the host page. See this article for a tutorial
Use a embedded browser engine like webkit and load your GWT module script in it.
Call the exported GWT functions as normal java functions.
But it will probably prove to be too much work, so you might be better off refactoring the servlets to expose another JSON/XML based interface in addition to RPC.
解决了,最好的方法就是塔希尔建议的那样。尝试直接从 C++ 连接到 GWT RPC 的工作量太大。最简单的方法是在服务器端像普通 servlet 一样编写瘦包装器,并使用 C++ 中的 http 和curl。关于对象序列化为 JSON 或 XML 的问题仍然存在。我选择在想要序列化的对象字段上编写自定义注释,然后在运行时读取这些注释以序列化它们。
Solved, the best way to go is as Tahir suggested. Trying to connect to GWT rpcs directly from C++ is just too much work. The easiest way was to write thin wrappers on the server side as normal servlets and use http and curl from C++. One issue remains about object serialization to JSON or XML. I elected to write a custom annotation on the object fields which I wanted to serialize and then read these annotations at runtime in order to serialize them.