WCF: Communicating with the ServiceHost?
Hey
This one's bugging me. I'm building a WCF service so that I can issue work to multiple clients and retrieve results back on the server (wsDualHttpBinding with callbacks). The WCF service is hosted in a WPF application using a ServiceHost.
I am curious how I communicate with the service from within the WPF application? Would I have to connect to the endpoint like the clients would have to? Once the clients have registered their callback with the service, i'd like to be able to invoke those callbacks from within the WPF app.
Re: WCF: Communicating with the ServiceHost?
Someone asked the same thing not long ago, see if their thread helps you at all: http://www.vbforums.com/showthread.php?t=584272
Re: WCF: Communicating with the ServiceHost?
Ah, i missed that thread. That gave me an idea... Singleton.
Step 1: Set the service to a singleton (which is what i really want):
Code:
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)]
Step 2: Set up the service
Code:
WCFService workService = new WCFService(controller);
ServiceHost host = new ServiceHost(workService);
host.Open();
Step 3: Call the service method
Code:
workService.CallMethod();
Thanks... the help is much appreciated. I feel silly for missing that. I didn't realise I could start the service with an instantiated object.
Re: WCF: Communicating with the ServiceHost?
Glad I could help point you in the right direction :)