Click here to Skip to main content
15,898,010 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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?
Posted
Updated 29-Aug-15 21:36pm
v2
Comments
Patrice T 30-Aug-15 3:27am    
No more details ?
Remember that we don't see your screen and we are not in your head.
ReachToTo 30-Aug-15 4:20am    
i have updated my question. Hope it is better now.
Sergey Alexandrovich Kryukov 30-Aug-15 23:10pm    
What, no information on the Web service? And what does your mention of C++ mean? do you mean that your Windows Service is written in C++? What does it mean "port the C++ process to windows?" Do you mean that you have some non-Windows project you want to use on Windows?
—SA

1 solution

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
 
Share this answer
 
Comments
ReachToTo 31-Aug-15 5:29am    
i understand the web service part. Can web service connect to another process or application to get the result?
Sergey Alexandrovich Kryukov 31-Aug-15 10:07am    
I already answered. Web service is always passive part. You send a request, it sends a response.
—SA
ReachToTo 1-Sep-15 6:24am    
Can the web service get the response from some other application or service? may be from windows service?
Sergey Alexandrovich Kryukov 1-Sep-15 8:43am    
What do you mean by the "get response" and "other"? Web service does not get response, it gets HTTP request and sends HTTP response. It sends the response where the request comes from. Do you understand TCP connection? HTTP is the protocol on top of TCP. Perhaps this is what you want to understand.
—SA
ReachToTo 1-Sep-15 9:29am    
The web service needs to call a method in windows service to get the result. How can this be done?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900