简体   繁体   English

如何将本地安装的应用程序公开为Web服务?

[英]How to expose locally installed application as Web Service?

Suppose I have 2 web services A and B in SOA project. 假设我在SOA项目中有2个Web服务A和B。 Both web services are running on a remote servers. 这两个Web服务都在远程服务器上运行。 Web Service A depends on information available from only a locally installed desktop application on a human actor machine and thats all web service A does ie provide this information). Web服务A仅依赖于可从actor机器上本地安装的桌面应用程序获得的信息,这就是所有Web服务A所做的,即提供此信息。 There are hundreds of such human actors with the same locally installed application providing its own information that web service A needs. 有数百个此类人类参与者具有相同的本地安装应用程序,它们提供Web服务A所需的自身信息。 Web service B needs this information from web service A, the result of which (which is the whole benefit of this project) is provided to that human actor who originated this process (by loging into system and clicking some command button). Web服务B需要Web服务A的此信息,其结果(这是该项目的全部收益)被提供给发起此过程的那个人类参与者(通过登录系统并单击某些命令按钮)。 So this human actor is acting like the consumer of Web service B. The question is how can I make this locally installed application act as Web Service A (in the context of SOA project)? 因此,这个人类参与者的行为就像Web服务B的使用者。问题是,如何使这个本地安装的应用程序充当Web Service A(在SOA项目的上下文中)?

This question could best be answered by some one with extensive experience in Web services and SOA. 这个问题最好由在Web服务和SOA方面具有丰富经验的人来回答。

This SOA project uses java, like ESB based on Java and there is no Microsoft specific services running although the desktop application is a Windows application. 该SOA项目使用Java,例如基于Java的ESB,尽管桌面应用程序是Windows应用程序,但是没有运行Microsoft特定的服务。 The application provides c/C++ API for an external process to call and retrieve the information needed by Web service A. What I want is the both web services A and B are hosted on remote server and interacting with each other via ESB but the problem is how to make local application information available to Web Service A? 该应用程序为外部过程提供c / C ++ API,以调用和检索Web服务A所需的信息。我想要的是Web服务A和B都托管在远程服务器上,并且通过ESB相互交互,但是问题是如何使本地应用程序信息可用于Web服务A?

There are two types of solutions 解决方案有两种

The first: have the original client application add a parameter with the address of web service A, and use this address for calling the service. 第一个:让原始客户端应用程序添加一个带有Web服务A地址的参数,并使用该地址来调用该服务。

The second: pass a more abstract user identifier from the client (actually, there's a good chance you have such a field in the service). 第二个:从客户端传递一个更抽象的用户标识符(实际上,您很有可能在服务中拥有这样的字段)。 and use a translation service to retrieve the physical address corresponding to this id. 并使用翻译服务检索与此ID对应的物理地址。 To allow such translation, the desktop application that acts as a server needs to "register" with the translation service when starting up. 为了允许这种翻译,启动时充当服务器的桌面应用程序需要在翻译服务中“注册”。

If you are using an ESB, or other SOA infrastructure (like a service directory, message queuing service) it will include much of the functionality you need to build the translation service. 如果您使用的是ESB或其他SOA基础结构(例如服务目录,消息队列服务),它将包含构建翻译服务所需的许多功能。

regarding the actual hosting of the service in the client machine. 有关在客户端计算机中实际托管服务的信息。

the simplest solution is to use a different process from the actual application, and just access the files or DB the application uses. 最简单的解决方案是使用与实际应用程序不同的过程,并仅访问应用程序使用的文件或数据库。 In this case you can use any infrastructure you like to develop the service. 在这种情况下,您可以使用任何喜欢的基础结构来开发服务。

a more complex scenario is when you need the actual application to supply the service. 一个更复杂的场景是当您需要实际的应用程序来提供服务时。 in this case you will need to have a thread in the application that listens to service requests. 在这种情况下,您将需要在应用程序中有一个线程来侦听服务请求。 if you are using WCF see Hosting Services about how to host a web service in your application. 如果您使用的是WCF,请参阅Hosting Services,以了解如何在应用程序中托管Web服务。

EDIT 编辑

some additions regarding you clarification. 关于您的一些补充说明。

as I understand, the desktop application exposes a C\\C++ API that is available for external processes on the same machine. 据我了解,桌面应用程序公开了一个C \\ C ++ API,该API可用于同一台计算机上的外部进程。

You can either write a web service that will use this API. 您可以编写将使用此API的Web服务。 Googling "C++ Web Services Windows" will give yo several relevant pointers on implementing those. 谷歌搜索“ C ++ Web服务Windows”将为您提供实现这些目标的几个相关指示。

Another good option is to use a messaging infrastructure. 另一个好的选择是使用消息传递基础结构。 most JMS providers provide API's in languages other then Java - including C++. 大多数JMS提供程序以Java以外的其他语言(包括C ++)提供API。 Your application will be a C++ windows service that listens and sends messages to you JMS provider. 您的应用程序将是一个C ++ Windows服务,它将侦听并将消息发送给您的JMS提供程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM