Results 1 to 4 of 4

Thread: WCF: Communicating with the ServiceHost?

  1. #1

    Thread Starter
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199

    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.
    If the facts don't fit the theory, change the facts. --Albert Einstein

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    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
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3

    Thread Starter
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199

    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.
    If the facts don't fit the theory, change the facts. --Albert Einstein

  4. #4
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: WCF: Communicating with the ServiceHost?

    Glad I could help point you in the right direction
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width