2
votes

I need to write server & client part. I need guidance how to start with WCF web-services.

I need to create WPF application that at the beginning will be simple UI for database tables, but later will consume data from server as WCF services. I was looking at LightSwitch, but it seems impossible to integrated it later with server part.

In Visual Studio 2010 after I create WPFApplication1 project I have Data Sources docked window. Data Sources

Then I can add new data source and select services Choose a data source type

What kind of WCF services should I create for WPF application?

I would like something like WCF RIA Services / Domain services, but they are only for RIA. At least no support from Microsoft. What is classic way for creating services for WPF application?

Related questions are :
Hosting WCF Rest Services in WPF Application
Architecting a WPF application with WCF Data Services
How to use WCF RIA SERVICES with WPF application?
WCF, Web services or ADO.NET data services: What shall I use?

1

1 Answers

3
votes

I would suggest you to create four projects for that porpouse:

  1. Yourapp.UI (XAML code and ViewModel)
  2. Yourapp.Data (Data Access Layer)
  3. Yourapp.Entities (Definition of your business objects)
  4. Yourapp.Services (Services Layer aka WCF)

Yourapp.Data talks to database and retrieves the desired information.

Yourapp.Services maps and transforms that information into your entities (if the logic involved is too complex, perhaps and aditional business layer would be required).

From Yourapp.UI just need to add a Service Reference and consume it like a IEnumerable<> and make it reusable so VS won't create additional objects but point to your entities.

Yourapp.Entities must be referenced in projects 1,3 and 4. This will make your development easier to test and debugable. Also try to use interfases at the service level so mock testing would be easy to implement.

Hope I was clear enough, I'm kind of tired. If any question aroses, add a comment please. Cheers.

Ok, I know it was more a theory answer rather than a practical one. May I suggest you to check these tutorials? MVVM Tutorials - WCF/WPF They are excellent introduction and happens to use WPF and WCF like you require.

A couple of months ago I found them in youtube and believe me, they cleared out a lot of doubts I had at that moment. Since then it's been a lot easier to master. At the beginning WCF can seem more complicated than what it really is.

Sorry for not extending my answer but I don't have much time at this moment. Hope it make more sense now.