locked
WPF with WCF service layer RRS feed

  • Question

  • Hi All,

    I need to build an application to be used internally in my organisation. It is a small data driven application with approximately 25 tables (excluding lookup and audit related). I am going to use WPF 4 to build this application. Now I would like to use WCF as a service layer too. I am new WCF. The advantages I can see in using WCF are

    1. I can have business and data layer at a central location and hence I don’t have to distribute BL / DL related updates to client machines.
    2. I don’t have to store the database connection string on client machines.
    3. I get to learn a new technology :)

    The disadvantages that I see are
    1. WCF introduces another layer to the application architecture adding more to the complexity and possibly affecting the performance. (Performance is not critical for this application)
    2. There are a lot of reports that need to be generated from the database and I am not sure about the best way of doing this in WPF/WCF
    3. I am new to the technology. (I have read a few tutorials and I have coded a few sample services as well. Currently reading Michelle Leroux Bustamante’s book)

    I would like to get some advices/opinions on having the WCF service layer in my application. I would also appreciate some guidance in creating reports in WCF and consuming them in WPF. Kindly help.

    Thank you

    Shameer

    Thursday, August 25, 2011 11:27 PM

All replies

  • ... 

    The disadvantages that I see are
    1. WCF introduces another layer to the application architecture adding more to the complexity and possibly affecting the performance. (Performance is not critical for this application)
    2. There are a lot of reports that need to be generated from the database and I am not sure about the best way of doing this in WPF/WCF
    3. I am new to the technology. (I have read a few tutorials and I have coded a few sample services as well. Currently reading Michelle Leroux Bustamante’s book)

    I would like to get some advices/opinions on having the WCF service layer in my application. I would also appreciate some guidance in creating reports in WCF and consuming them in WPF. Kindly help.

    Thank you

    Shameer

    Actually, WCF can be less complex in many areas. Web-services very good from the operations point of view. More flexible.
    You can create the operations to request reports.
    All development is very easy. Create your interfaces, add contract attributes and it is pretty much all additional effort. Other effort is irrelevant to WCF. All complex stuf (proxy, WSDL, XSD-s etc.) is generated automaticaly.

    Hosting in IIS gives a lot of scalability


    Leonid Ganeline [BizTalk MVP] BizTalk: Sample: Context Routing and Throttling with orchestration
    Friday, August 26, 2011 4:28 AM
  • Hi,
    The advantages of WCF is clearly evident once we see the power it delivers to products not only during development, but also in implementation and maintanence.

    Let me explain as to what I am trying to convey:
    1. WCF clearly demarcates development and implementation. All the development part lies in the code while the implementation like the binding you choose or the security model you embrace can be handled in the config file. COM+ or realted technologies will not give you this advantage. This is what WCF means when it says they reduce plumbing time. Developer concentrates on what he wants to achieve and WCF takes care of delivering it to the outer world in the most reliable, secure and high performance fashion. WCF also scores over remoting by giving out of box solutions to publish code as Web services. The out of box solutions are more simple to implement and have less overheads.
    2. WCF opens up communication with other applications communicating from various platforms. The fast development power of .net combined with the fast delivery power of WCF makes the market reach time very minimal. Along with this when we add inter operatability, WCF simply reaches out further. This statement doesn't mean that a WCF service runs on Linux but can talk to any app written based on certain set of protocols specified by WCF. In the Web world this means it is available on every major browser. With other technologies, achieving the same requires lots of tweaking but it is available out of box when you embrace WCF.
    3. Hosting a WCF service is very simple on IIS 7 or WAS in Vista or WIN 2K8. In WIN 2K3 and WIN XP SP2 it can be hosted on IIS 6 for the HTTP mode and as a  WIndows service or even self hosting will do.  To achieve the same too it takes minimal efforts.
    4. WCF has an integrated Logging mechanism that helps you log traces that become a boon during maintanence. In other technologies, developer has to do some work to achieve this but in WCF, all that we have to do is to enable trace by changing the config file and WCF starts providing traces for you.
    5. Security mechanism in WCF is fairly simple and out of box when you look from the implementors perspective but is very robust and highly secure. The best part is that for the highy used and recommended bindings, WCF provides default security which can be trusted to the core. The message security on WSHTTPbinding is an example on these lines.

      To understand more about WCF service refer the follosing URL http://msdn.microsoft.com/en-us/library/bb332338.aspx

    Regards

    Friday, August 26, 2011 6:41 AM
  • Hi,

    Thank you very much for your valuable suggestions. It is highly appreciated. I think I am going to use WCF in my project.

    Thanking you once again

    Shameer

     

    Monday, August 29, 2011 2:20 AM
  • Hi Shameer,

    Do take a look at Layered Architecture Sample for .NET to get an idea of how to hook up Presentation (UI) to a service backend (WCF). WCF will allow you to centralize your backend logic.

    As for your reports, do consider what data you are bringing to your UI. Frequent movement of large volumes of data across WCF boundaries is not recommended. If you really must do it, consider using WCF streaming.

    Hope it helps

    Serena 

    Wednesday, August 31, 2011 1:36 AM
  • Thank you Serena for your suggestions as well as the link to the architecture sample resource. I appreciate it.

    Shameer

     

    Friday, September 2, 2011 7:57 AM
  • I disagree with the other advice which has been given.

    WCF is an unecessary complication if you are on an intranet.

    If WCF RIA played nice with WPF then that would be a good reason to consider it.

    It doesn't though.

    Distribute your application with clickonce and you don't care where the layers are.

    And if you use integrated role based security there will be no passwords in the connection strings.

    Who cares if the users in your company can look in your exe and work out where the database server is?

     

    I'd recommend use Entity framework.

    Centralise your business logic in that.

    There's enough to learn in wpf and EF.

     

    Your reports.

    I notice nobody offered any advice on this aspect.

    I wonder if that's significant.

    Anyhow.

    Usually best handled in a winform using the report viewer control.

    That means you can develop using crystal reports or ssrs.  Both of which are pretty easy.

    With crystal you're best designing against a temporary table or stored procedure.

    At run time extract your data separately and present it to the crystal report.

    You can change the source at run time and so long as the list of fields and types matches up you're sorted.

    You can also easily show the data in some other form prior to reporting - like summaries.

     

    Whether you use wcf or whatever expose iqueryable and use the pipes and filters pattern for flexible reporting criteria.

    Friday, September 2, 2011 6:58 PM
  • Thanks everyone who responded. I ended up not using WCF in my project. I guess I have enough trouble with WPF and EF 4.0 :). I appreciate everyone's suggestions.

    Best regards

    Shameer

    Wednesday, October 19, 2011 11:17 PM