locked
WCF Service Library working "independently" RRS feed

  • Question

  • I have a WPF application which reads data from a USB device every few seconds, displays the data in a window, and periodically ftps the data to a web site, and saves it in an SQLite database.

    I would like to split it so that the WPF application becomes simply a 'viewer', and the part that does everything else becomes a Windows Service. The client/viewer would just connect as required to view the data, and it would also need to perform administrative actions like setting the period of the ftp updates etc. The client may or may not be running on the same PC as the service. So I need a way for the client to communicate with the service, and I am wondering if a WCF Service Library hosted in a Windows Service would be suitable? All of the examples I have seen of this involve simple "say hello" request/response where the service just responds to a poke from the client. It's not clear to me whether the WCF service can perform all of the timer-driven stuff that I would need it to do?

    Please note that I am very new to WCF and even Windows Services!

    Steve
    Wednesday, December 16, 2009 12:33 PM

Answers

  • Hi,
    Think WCF should help you with it .You can use Windows service to host a WCF service.
    See this link for help on this.Also this .

    For a sample application in WCF see this

    Feel free to ask if you need any clarification.

    Hope it helps
    Please mark posts as answers/helpful if it answers your query. This would be helpful for others facing the same kind of problem
    Wednesday, December 16, 2009 12:51 PM
  • You don;t need to use a service library

    Just create your ServiceHost for your service and open it in the OnStart override and close it in the OnStop. That will cause the windows service to listen for incoming requests over WCF. Your service can start timers, perform FTP requests, etc quite happily.

    As far as comparing console apps and windows services: rememebr that you don;t have a UI for the service so messages have to be sent to a log file or the system event log. Also the windows service will run under a different user account than a console app and so you need to ensure that that user account has access to any resources it uses
    Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
    Twitter: richardblewett
    Thursday, December 17, 2009 2:06 PM
  • Hi Steve,

    As other members mentioned, WCF would be a good choice for you to expose the data communication or service control/manipulation interfaces for local or remote client applications. Also, for local intranet environment, you can different options about the transport protocol to use. Here are some built-in bindings supported by WCF:

    #System-Provided Bindings
    http://msdn.microsoft.com/en-us/library/ms730879.aspx

    Also, another thing you should consider is how you will secure your service(authenticate the client):

    #Security Overview
    http://msdn.microsoft.com/en-us/library/ms735093.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by steveloft Tuesday, December 22, 2009 10:45 AM
    Monday, December 21, 2009 6:45 AM

All replies

  • Hi,
    Think WCF should help you with it .You can use Windows service to host a WCF service.
    See this link for help on this.Also this .

    For a sample application in WCF see this

    Feel free to ask if you need any clarification.

    Hope it helps
    Please mark posts as answers/helpful if it answers your query. This would be helpful for others facing the same kind of problem
    Wednesday, December 16, 2009 12:51 PM
  • Are there any restrictions on what I can do in a WCF Service Library compared to a .NET Console Application?

    Steve
    Thursday, December 17, 2009 12:07 PM
  • You don;t need to use a service library

    Just create your ServiceHost for your service and open it in the OnStart override and close it in the OnStop. That will cause the windows service to listen for incoming requests over WCF. Your service can start timers, perform FTP requests, etc quite happily.

    As far as comparing console apps and windows services: rememebr that you don;t have a UI for the service so messages have to be sent to a log file or the system event log. Also the windows service will run under a different user account than a console app and so you need to ensure that that user account has access to any resources it uses
    Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
    Twitter: richardblewett
    Thursday, December 17, 2009 2:06 PM
  • Hi Steve,

    As other members mentioned, WCF would be a good choice for you to expose the data communication or service control/manipulation interfaces for local or remote client applications. Also, for local intranet environment, you can different options about the transport protocol to use. Here are some built-in bindings supported by WCF:

    #System-Provided Bindings
    http://msdn.microsoft.com/en-us/library/ms730879.aspx

    Also, another thing you should consider is how you will secure your service(authenticate the client):

    #Security Overview
    http://msdn.microsoft.com/en-us/library/ms735093.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by steveloft Tuesday, December 22, 2009 10:45 AM
    Monday, December 21, 2009 6:45 AM
  • Thanks for the answers, everyone. Apologies for not having marked answers, but I am still trying to get my head around this very new (to me) technology. I think I will have to buy a book!

    I do seem to have a simple prototype working, though :)

    Steve
    Tuesday, December 22, 2009 10:44 AM