Solved

WCF: Server to Client

Posted on 2009-05-02
3
483 Views
Last Modified: 2013-11-08
I want to write a windows service and install it on about 15 computers spread throughout different states.  I also have a separate web server that is located in Texas.  The windows service on each computer should do a specific task when instructed by the Web server.  The clients with teh windows services can't take this action based on polling (such as polling every 5 minutes to the web server) because what the clients have to do is sensitive down to the second.

I would like to know if this is possible.  I know that I can have the windows service on each client contact the web server and query it or ask it a question, but can the webserver contact a specific client, sent it an xml string and expect a return answer?  again, the client (windows services) can't poll the web server...it has to be done the other way around.

Any help is appreciated, if you can get me pointed in the right direction I would greatly appreciate it!
0
Comment
Question by:volumeIII
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 24290110
In your scenario, the Client is not the Windows service, the client is the WebServer. So the windows service on computers would have to act as a server listening on may be tcp/ip ports for incoming webserver requests, processing them, and reply to the webserver.
0
 
LVL 11

Accepted Solution

by:
CMYScott earned 500 total points
ID: 24297613
We are working thru this same scenario right now on our project.  The answer is "yes" it can be done.  I've gotten it to work using CallbackContract in WCF which required a bi-directional communication method (I'm using wsDualHttp right now).  For performance reasons, I'm trying to use netTcp bindings and struggling a bit.

I think this is the link to one of my main sources of example for creating my callback implementation (there are others as well if you google 'wcf callback')

http://dotnetaddict.dotnetdevelopersjournal.com/wcf_alarmclock.htm

Essentially, you have to support a subscribe/unsubscribe method in your WCF Service as well as an Interface for a callback method.  That interface needs to be implemented in your client class as well.  When the client subscribes, it passes a context to the implementation of the callback method.  Whenever your service needs to notify clients of events, it loops thru the collection of subscribers and raises the callback method on the client via the context that was passed during the subscription event.

Good Luck,
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Summary Displaying images in RichTextBox is a common requirement with limited solutions available. Pasting through clipboard or embedding into RTF content only support static images.  This article describes how to insert Windows control objects int…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now