我什么时候应该在 Odoo 中使用 XML-RPC 而不是控制器? [英] When should I use XML-RPC instead of a Controller in Odoo?

查看:21
本文介绍了我什么时候应该在 Odoo 中使用 XML-RPC 而不是控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对这两个交换信息的概念感到非常困惑.我 几天前问了一个问题,看来我做错了.

I'm very confusing with this both concepts of exchanging information. I asked a question few days ago and it seems I was doing wrong.

控制器是 Web 服务还是某种类型的服务?只有 XML-RPC 是 Web 服务?

Are the controllers web services or kind of? Only XML-RPC is a web service?

所以我想知道什么时候应该使用 controller 以及何时应该使用 XML-RPC 在 Odoo 和任何其他不同的应用程序之间交换信息.

So I would like to know when I should use a controller on Odoo and when I should use XML-RPC to exchange information between Odoo and any other different application.

哪种方式最安全?

在我之前的问题中,我希望客户向我发送有关某些客户的信息以在数据库中创建它们.有人发表了评论建议我用 XML-RPC 来做这件事.那么在哪些情况下我应该使用控制器?是否仅在我想将网站发回给客户端作为响应时才使用?

In my previous question I wanted the client to send me information about some customers to create them in the database. Somebody posted a comment recommending me to do it with XML-RPC. So in which cases should I use a controller? Is it only used if I want to sent back a website to the client as a response?

我在 Odoo 文档中没有找到任何线索.但是,我在 Odoo 文档中找到了一些语言(Python、Ruby、PHP、Java)的 XML-RPC 示例.如果向我发送信息的客户端不使用这些语言,那么使用控制器做这些事情可能会更方便.是吗?

I didn't find any clue in the Odoo documentation. However I found some XML-RPC examples in some languages (Python, Ruby, PHP, Java) in the Odoo documentation. Maybe to do the things with a controller is more convenient if the client, who sends me the information, does not work with those languages. Is it?

我将不胜感激.

推荐答案

如果您只是使用 CRUD(创建、读取、更新、删除),您几乎肯定想要使用 xmlrpc/jsonrpc 接口.您甚至可以使用 xmlrpc/jsonrpc 在您的模型上执行自定义命令.因此,xmlrpc 是一种在客户端和服务器之间执行经过身份验证的交换的结构化方法.

If you are simply using CRUD (Create,Read,Update,Delete) you almost definitely want to use the xmlrpc/jsonrpc interfaces. You can even you xmlrpc/jsonrpc to execute custom commands on you models as well. So xmlrpc is a structured means of executing authenticated exchanges between your client and the server.

如果您想将复杂的 json 数据提供回您的客户端或从客户端-> 服务器进行未经身份验证的交互,那么控制器绝对是您的最佳选择.

If you want to provide complex json data back to your client or make unauthenticated interactions from client->server then a controller is definitely the way to go.

控制器对于 Odoo 网页服务也非常有用.使重定向到适当的页面或加载适当的模板和处理表单数据变得非常容易.

Controllers are also very useful for the Odoo Webpage services. Making redirecting to the proper page or loading the appropriate template and handling form data very easy.

任何适合您的设计需求的方法都可能适合您,但是 Odoo 已经创建了用于处理正常 CRUD 交互和执行模型功能的服务,建议您从 Odoo 的工作中受益,并利用您辛苦的编程时间来创建您自己的结构,其中需要.

Whatever works for your design needs may be correct for you, however Odoo has created services for handling normal CRUD interactions and executing model functions and it is advisable to benefit from Odoo's work and use your hard programming time to create your own structures where needed.

这是 Odoo 的文档.

Here is Odoo's docs.

xmlrpc

这篇关于我什么时候应该在 Odoo 中使用 XML-RPC 而不是控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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