0

Here is what I want to do:

  1. Have a windows service that hosts a WCF service. This service also will get notifications from SQL Server via SQLDependency.
  2. When the windows service gets notified by SQL Server that something has changed, I want it to initiate a callback to all the clients via the WCF service it is hosting.

Here's what I have so far:

  1. A WCF service that has the callback etc. It works and the clients receive the call back (but so far only if the client sends a message first!).
  2. The windows service hosting the WCF service, and getting the SQLDependency notifications

Here's where I have fallen on my face:

  1. How do I get the windows service to notify the WCF service that it should send the message to the clients?
richard
  • 12,263
  • 23
  • 95
  • 151

1 Answers1

1

Create a public method on your WCF service that can be called by your Windows service that will initiate the callback to all the clients. Then add the WCF service reference to your Windows service and it should be easy from there.

Mikecito
  • 2,053
  • 11
  • 17
  • All I have in the windows service is this `ServiceHost myService = new ServiceHost(typeof(MyService.MessageService)); myService.Open();` How do I then call a public method on the WCF service (`MyService.MessageService`)? – richard May 13 '11 at 21:46
  • Ok I figured it out. I needed to start the service like this instead: `MyService.MessageService newMyMessageWCFService = new MessageService(); ServiceHost myService = new ServiceHost(newMyMessageWCFService);` as well as add this attribute to my service: `[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]`. – richard May 13 '11 at 22:03