连接到进程的Web服务 [英] Web service to connect to a process

查看:65
本文介绍了连接到进程的Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Windows服务会进行一些后端处理。如何从Web服务连接到Windows服务以获得结果?



客户端=> Web服务=> Windows服务(或)c ++进程。



当客户端调用Web服务时,该服务需要在c ++进程中调用一个方法,该方法将执行一些电话操作。



我不确定网络服务如何与其他进程通信。通过插座?或者我是否需要将c ++进程移植到Windows?

My windows service does some backend processing. How can i connect from web service to the windows service to get the result?

Client => Web Service => windows service (or) c++ process.

When a client calls a web service, the service needs to call a method in the c++ process, which will perform some telephony operation.

Im not sure how a web service can talk to other processes. Via socket? Or do I need to port the c++ process to windows?

推荐答案

不,根据定义,Web服务通过HTTP进行通信。更准确地说,它通常应该通过纯客户端服务技术使用:您发送HTTP请求,服务器通过HTTP响应进行响应。请参阅:

https://en.wikipedia.org/wiki/HTTP [< a href =https://en.wikipedia.org/wiki/HTTPtarget =_ blanktitle =New Window> ^ ],

https://en.wikipedia.org/wiki/Web_service [ ^ ]。



在较低级别,任何HTTP库都允许你这样做即: http://kukuruku.co/hub/cpp/a- cheat-sheet-for-http-libraries-in-c [ ^ ]。



但是,正如您所看到的,Web服务可能不同,所以消费服务的实际方法取决于它是什么。可以从广义或狭义的角度理解这个词(参见上面的第二个参考文献)。从狭义上讲,该服务以机器可处理的格式进行描述,标准化为WSDL: https://en.wikipedia.org/ wiki / Web_Services_Description_Language [ ^ ]。



在这种情况下,您可以使用更专业的客户端库来提供序列化方法的编组,等等,这样客户端部分就会以某种方式运行基于接口函数的调用,它实现为代理,其中包含HTTP和网络流。该服务可以使用或不使用SOAP,是休息服务或任意,等等。



充当REST的客户端服务,您可以使用适当的API: https://msdn.microsoft.com/en-us/library/ jj950081.aspx [ ^ ]。



对于充当SOAP客户端,您可以查看此CodeProject文章: C ++的SOAP客户端 [ ^ ]。



另见本文: http://www.drdobbs.com/cpp/web-services-c/184405505 [ ^ ]。



等等上。在进行一些研究并找出您想要使用的服务之前,您几乎无法获得所有相关说明。从广义上讲,它可以是属于上面引用的Wiki(第二个链接)中所示的Web服务的非常通用定义的任何内容。我甚至看到了请求数据放在URL查询参数中的情况;他们仍称这种原始技术为Web服务。您需要找出您的案例真正需要的内容。



-SA
No, a Web service, by definition, talks via HTTP. More exactly, it is generally supposed to be used via the pure client-service technology: you send HTTP request, the server responds by HTTP response. Please see:
https://en.wikipedia.org/wiki/HTTP[^],
https://en.wikipedia.org/wiki/Web_service[^].

At the lower level, any HTTP library will allow you to do that: http://kukuruku.co/hub/cpp/a-cheat-sheet-for-http-libraries-in-c[^].

But, as you can see, Web services can be different, so the practical ways to consume a service depends on what is it. It can be understand in wide or narrow sense of this word (see the second reference above). In more narrow sense, the service has description in a machine-processable format, standardized as WSDL: https://en.wikipedia.org/wiki/Web_Services_Description_Language[^].

In this case, you can use more specialized client libraries which provide serialization marshaling of methods, and so on, so the client part would act in a way bases on the call of interface functions which are implemented as proxy with the HTTP and network streams under the hood. The service can use SOAP or not, be a rest service or arbitrary, and so on.

To act as a client of a REST service, you can use appropriate API: https://msdn.microsoft.com/en-us/library/jj950081.aspx[^].

For act as a SOAP client, you can look at this CodeProject article: SOAP client for C++[^].

See also this article: http://www.drdobbs.com/cpp/web-services-c/184405505[^].

And so on. You hardly can get all relevant instructions until you do some research and find out what the service you want to use really is. In wide sense of this word, it can be anything which would fall in a very generic definition of Web service shown in the Wiki referenced above (second link). I even saw the cases where the request data is put in URL query parameters; and they still call this primitive technology "Web service". You need to find out what your case really requires.

—SA


这篇关于连接到进程的Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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