我应该如何使用 Catalyst 在 Perl 中进行 RPC?

发布于 2024-08-20 12:04:55 字数 953 浏览 4 评论 0 原文

我一直在努力寻找一种好的 RPC 形式来标准化,但到目前为止我遇到了很多困难,并且想知道 stackoverflow 社区的观点是什么。

我理想的 RPC 将提供以下功能:

  • 对其他语言有一定的广泛支持,因为人们不必编写自定义堆栈来使用我们的服务器
  • 输入验证
  • 理想情况下,可以通过某种方式将上述输入验证转换为某种自动化文档分发
  • 干净且可维护的代码

我是 Catalyst 框架的粉丝,并且更愿意坚持使用它,但如果有一个明显更好的 RPC 服务器替代方案,我也会对此持开放态度。

到目前为止,我已经查看了以下内容:

Catalyst::Controller::SOAP 似乎不支持返回复杂的数据结构,仅支持 string('literals')。我可能可以在此基础上序列化数据,但这看起来很老套。它还允许您返回预先形成的 XML 对象,但我无法使其工作,并且看起来您需要重新创建大量 SOAP 数据结构才能使其工作。

我确实喜欢 WSDL 的想法,但整体规范的复杂性也让我想知道对与其他语言通信的支持有多好。

基于自定义 POSTing XML 的控制器 我们尝试以类似于我们最近看到的其他两个项目的方式来手动推出自己的项目,其中有一个可以将 XML 发布到的调度 URL。这使您可以拥有 XSD 验证/文档,但需要创建的代码比我们目前想要维护的代码多得多。

Catalyst::Plugin::Server::XMLRPC 发出有关使用已弃用的方法的警告,该方法将在 Catalyst 的未来版本中删除。 没有输入验证或文档创建,但除此之外是我发现的最好的

JSONRPC 看起来与 XMLRPC 非常相似,只是模块实际更新了。接下来我可能会选择这个,除非有人提出更好的建议 催化剂似乎还有两个不同的模块可以执行 JSONRPC

I've been trying to find a good form of RPC to standardize on, but so far I've ran into a ton of walls and was wondering what the stackoverflow communities view was.

My ideal RPC would provide the following:

  • Somewhat wide support in other languages, in that people shouldn't have to write a custom stack to use our server
  • Input validation
  • Ideally, some way to turn the above input validation into some sort of automated documentation to distribute
  • Clean and maintainable code

I am a fan of the catalyst framework and would prefer to stick to it, but if there is a clearly better alternative for RPC servers I'd be open to that as well.

So far I have looked at the following:

Catalyst::Controller::SOAP
Doesn't appear to support returning of complex data structures, only string('literals'). I could probably serialize data on top of that, but that seems very hacky. It also lets you return a pre-formed XML object, but I couldn't get that to work and it looks like you'd need to re-create a lot of SOAP data structure for it to work.

I do like the idea of WSDLs, but the complexity of the overall spec also makes me wonder how well support for communicating with other languages will be.

Custom POSTing XML based controller
We tried to roll our own by hand in a similar way to how we've seen two other projects do it recently where there is a dispatch url that you post XML to. This lets you have XSD validation/documentation, but required creating a lot more code than we want to maintain at this point.

Catalyst::Plugin::Server::XMLRPC
Gave a warning about using a deprecated method that will be removed in a future version of Catalyst.
No input validation or doc creation, but otherwise the best I've found

JSONRPC
Looks pretty similar to XMLRPC only the module is actually updated. I'll probably go with this next unless someone suggests something better
There also appears to be two different modules for catalyst that do JSONRPC

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

阿楠 2024-08-27 12:04:55

我意识到 REST 不是纯 RPC(只是一个子集),但是...

我会推荐 Catalyst::Controller::RESTCatalyst ::Action::REST 模块。它们经常更新,并且文档也相当不错。还有一个使用 Catalyst::Controller 的好(但相当过时)示例: :在 2006 年 Catalyst Advent 日历中休息,标题为 第 9 天 - 使用 Catalyst 的 Web 服务::行动::休息

I realize that REST isn't pure RPC (only a subset), but...

I would recommend the Catalyst::Controller::REST and Catalyst::Action::REST modules. They're frequently updated and the documentation is fairly good. There is also a good (but rather dated) example of using Catalyst::Controller::Rest in the 2006 Catalyst Advent calendar titled Day 9 - Web Services with Catalyst::Action::REST.

黎夕旧梦 2024-08-27 12:04:55

FWIW,Catalyst::Controller::SOAP 确实支持返回复杂数据。查看文档 http: //search.cpan.org/~druoso/Catalyst-Controller-SOAP-1.23/lib/Catalyst/Controller/SOAP.pm,这将向您展示可以使用 WSDL 来描述您的服务。另请参阅 http://daniel.ruoso.com/categoria/perl/ Soap-today.html.en 了解更详细的分步过程。

FWIW, Catalyst::Controller::SOAP does support returning complex data. Take a look at the documentation http://search.cpan.org/~druoso/Catalyst-Controller-SOAP-1.23/lib/Catalyst/Controller/SOAP.pm, which will show you that you can use a WSDL to describe your service. Also, see http://daniel.ruoso.com/categoria/perl/soap-today.html.en for a more detailed step-by-step process.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文