运行 VI 时自动启动项目特定的 Web 服务

Starting a project-specific web service automatically when running a VI

我有一个项目设置了网络资源,如下图所示:

目前,如果我想要TemperatureService接受连接,我需要右击它然后选择开始。这有点不方便,但更重要的是,这些工具的操作员需要额外的步骤,这可能会由于健忘、无意识等原因导致意外的人为错误。

因此,我希望能够在运行这个项目中的某个VI时自动启动TemperatureService。到目前为止我已经找到了几个 resources/tutorials 1, 2, 3, but all I could gather was how to auto-start the admin interface of the web service, which is done by adding the following blocks to the VI (mainly Open Application Reference):

... 没有启动服务。我也尝试将 Property Node 的 属性 设置为 Server:TCP Listener Active,但这也没有达到预期的效果。

总结一下:如何在 运行 VI 时自动启动特定的 Web 服务?

我在 64 位 Win 7 上使用 LabVIEW 2015 运行。

通过在 NI 站点上关注 this tutorial,我能够成功创建一个持续的 Web 服务,该服务在退出 LabVIEW 并重新启动计算机(或至少是 VM)后继续 运行其中我 运行 LabVIEW).

如教程中所述,如果您通过在项目中右键单击 Web 服务并选择 启动 来启动 Web 服务,则调试中的服务 运行s当您退出 LabVIEW 时终止的服务器。

然而,当您选择 Application Web Server > Publish 时,LabVIEW 的应用程序 Web 服务器中的服务 运行 并在退出 LabVIEW 后继续 运行 并且重启电脑后。

请注意,应用程序 Web 服务器 运行 位于与调试服务器不同的端口;发布服务后,右键单击方法 VI 并选择 显示方法 URL... 以查看正确的地址。

如果部署失败并显示错误 Target OS for this Web service differs from the Web server configuration,请确保服务器是 configured for the same runtime(即 32 位或 64 位)作为 LabVIEW 开发环境。