Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

WCF: Server to Client

Posted on 2009-05-02
3
Medium Priority
?
494 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 2000 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

926 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