PDA

Click to See Complete Forum and Search --> : WCF: Communicating with the ServiceHost?


Rockhopper
Oct 8th, 2009, 03:09 PM
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.

chris128
Oct 8th, 2009, 04:00 PM
Someone asked the same thing not long ago, see if their thread helps you at all: http://www.vbforums.com/showthread.php?t=584272

Rockhopper
Oct 8th, 2009, 04:32 PM
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):


[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Single, InstanceContextMode = InstanceContextMode.Single)]


Step 2: Set up the service



WCFService workService = new WCFService(controller);
ServiceHost host = new ServiceHost(workService);
host.Open();



Step 3: Call the service method

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.

chris128
Oct 8th, 2009, 04:53 PM
Glad I could help point you in the right direction :)