0

I have now a WCF service that is hosted inside a WPF application. It's running in a WCF server-client scenario where the client can call the server as well (duplex communications).

I would like to host the WCF client in a windows service, but I'd like to keep the WPF UI because of the functionality it provides when making calls back to the server (e.g. request information). I know that windows services don't have UI, but in this case I need it.

What best way is there to communicate between the WPF application and the windows service? (something better than sockets maybe?)

A scenario where this is useful would be something like:

  • from the WPF application I can choose what kind of information would be required from the WCF service acting as server,

  • this "command" would be sent to the windows service hosting the WCF client instance, and using the the instance making the call to the server and

  • displaying the information in the WPF application via the WCF client service hosted by the windows service.

Thanks, Adrian

Adrian
  • 743
  • 9
  • 29

1 Answers1

1

Since the service is already running as WCF, how about exposing some extra "admin" methods on the WCF interface and have the WPF application interact with the service through those?

You'd have to put in a security layer to make sure only the legitimate user could call those new methods, but this solution might be the least work since the WCF infrastructure is already in place.

Stephen Holt
  • 2,360
  • 4
  • 26
  • 34
  • I would limit the WCF client service to only allowing 1 connection, and I would provide a secret key or something similar that I can hardcode in both applications. By exposing the extra methods on the WCF interface you mean I should also implement a WCF client in the WPF application so I can call these methods (and basically have a duplex scenario between the WPF application and the Windows Service?) – Adrian Nov 14 '12 at 12:38
  • Yes, that is basically what I mean. The accepted answer to this post: http://stackoverflow.com/questions/9125442/best-practice-for-wcf-duplex-client explains why actual duplexing is a bad idea, and suggests just setting up a WCF host at the client end. Out of interest, what messages does the server need to send to the WPF client? If it's just for status updates or other information about the service, and there's just one instance of the client, could you just use regular polling instead to update what's in the WPF client? – Stephen Holt Nov 14 '12 at 16:55
  • Damn, why didn't I find that answer before started implementing? :) Thanks for you help! – Adrian Nov 15 '12 at 09:11