本文介绍了使用Worklight Adapter,我可以在运行时更改过程的域和端口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个worklight应用程序,它将连接到各种后端服务,这些服务将在安装后由消费者决定。我想使用适配器将客户端连接到后端服务 - 但是要避免为每个连接用户编辑和更新适配器。

I am writing a worklight application and it will be connecting to a variety of backend services which will be decided by the consumer after installation. I would like to use adapters to connect the client to the backend services - but want to avoid editting and updating the adapter for each connecting user.

基本上每个客户都在运行我想连接的服务器 - 但是它将在每个客户的不同端口和域上运行。我希望他们能够将这些传递给适配器以允许向客户的后端服务器发出公共呼叫。

Essentially each customer has a running server I want to connect to - however it will be running on a different port and domain for each customer. I want them to be able to pass those to the adapter to allow a common call to be issued to the customer's backend server.

有没有办法可以改变域和端口我在适配器的xml文件中以编程方式在适配器的javascript中为每个过程设置,以便用户可以告诉服务器在哪里发出请求?

Is there a way that I can alter the domain and port I set in the adapter's xml file programmatically inside the adapter's javascript for each procedure so the user can tell the server where to issue a request to?

如果有无法做到这一点 - 你会建议直接连接到后端并避免使用worklight适配器吗?

If there is no way to do this - would you recommend connecting directly to the backend and avoiding the use of worklight adapters?

非常感谢,

Andy

推荐答案

正如您所猜测的那样 - 客户端(app)向Worklight发送适配器过程请求服务器然后执行它编程要执行的任务,连接到它被要求的位置(如适配器XML的 connectionPolicy 元素中所定义)。这在运行时/部署后无法更改。

As you have correctly guessed - the client (app) sends an adapter procedure request to the Worklight Server, which then executes whichever it has been programmed to do, connects to where it was asked to (as defined in the adapter XML's connectionPolicy element). This cannot be changed during runtime/once deployed.

我不知道您的应用应该做什么,因为情景并不完全清楚......但是你可以为所有各种后端及其连接参数集预先部署所有必需的适配器,并在客户端编写一些逻辑以确定要使用哪个适配器。这里肯定会有适配器重复,但它不应该在运行时产生太多开销(但是可维护性是的)。

I don't know what your app is supposed to do, as the scenario is not entirely clear... but you could pre-deploy all required adapters for all the various backends and their set of connection parameters, and on the client-side write some logic to determine which of the adapters to use. There will definitely be adapter duplication here, but it shouldn't create too much overhead on runtime (but yes on maintainability).

是的,你也可以创建自己的接口允许最终用户在向后端发送直接请求之前更改连接参数(即,不使用Worklight Adapters),但这听起来不像最终用户需要嘲笑的东西。

And yes, you could also create your own "interface" to allow the end-user to change the connection parameters prior to sending a direct request to the backend (that is, not use Worklight Adapters), but this doesn't sound like something an end-user needs to mock around with.

这篇关于使用Worklight Adapter,我可以在运行时更改过程的域和端口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 01:11