views:

45

answers:

4

Hi,

I am building a Winforms client that needs to communicate with a backend. This backend is build using Nhibernate (with a VERY rich domain model) , message queuing and other.

Now i do know about communicating over the internet ( mostly mq stuff) but i am at total loss as to how to let my Client Winforms App talk to the Application server to call the services.

What is the best way to do this ? I've read all about Nhibernte , DDD, WCF, remoting etc, but i just don't see how to do this the right way? How to design the services ( since the model is so extended, it would be a VERY chatty interface vs a VERY chunky interface)

So Basically: What is the best way to let a winforms app talk with the backend ( layering) and are there any good examples as to how to implement this ( including all layers because most examples stop at the Service Boundry :s)

A: 

I would personally like to go for lean REST+JSON using ASP.NET MVC but the safest bet is WCF. There are tons of examples here:

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=35ec8682-d5fd-4bc3-a51a-d8ad115a8792&displaylang=en

In terms of desiging the interface, break down the calls to the granular functionalities.

Aliostad
So you get something like: client <-> View <-> Model/Controller <-> WCF Service <-> Services <-> Model/Repository ?
Noctris
Yes, I would say so. Other alternative is client <-> View <-> Model/Controller <-JSON+REST-> ASP.NET MVC <-> Services <-> Model/Repository
Aliostad
+1  A: 

I would use WCF and several interfaces to define the services which is used to access the backend.

Application.BusinessLayer

Defines all WCF interfaces + domain entities. Used by the winform and backend.

A interface can look like this:

[ServiceContract]
public inteface IUserService
{
    [OperationContract]
    IEnumerable<User> Find(string searchWord);
}

That's all you need to define a WCF service.

Application.Service

Your backend. Implements all interfaces.

You can either configure WCF using the config file or by code. The WCF services can either run inside a ASP.Net application or a ServiceHost.

Application.WinClient

You winform application.

You can add a service reference if your application to your webservice if you host your WCF services in asp.net. Else you use ChannelFactory to create your service proxies.

jgauffin
+1  A: 

I liked the approach described in this MSDN article by Ayende, though have not tried it myself.

Worth checking out.

liggett78
A: 

As an alternative to the RPC (Remote Procedure Call) provided by WCF, you can also consider to have your backend implemented as a service communicating via messages.
You can design such service to communicate one-way and/or request-response.
To implement the communication between applications via messages, you can consider to use Eneter Messaging Framework. It is lightweight and your applications can communicate based on NamedPipes, Tcp or Http.
If you are interested, you can get more technical info here.
Or more examples you can find on eneter.blogspot.com and the framework can be downloaded from www.eneter.net.

Ondrej Uzovic