4
votes

I'm a newbie when it comes to client/server app. (I only programmed asp.net apps)

I want to create an application that contains of multiple WinForm clients and a .NET Server (I'm thinking about WCF). Communication between client and server should be on http (port 80).

Application Scenario:

The client will pass a keyword to the server, for example 'books'.

The server will then start a 1sec - 10mins process of search matching data based on this keyword.

The server will find a list of results (from 1 result to N results).

I would like the client to update the GUI with found results while the server is searching. (Not wait until the server is finished).

My questions are:

Is WCF the right choice for the server side?

What kind of WCF protocol? Duplex, polling, MSMQ based?

Any links to related example code , starter-kit ,etc are welcome :)

2

2 Answers

1
votes

If you're using WCF, MSMQ would be the transport layer ("binding" to use the WCF terminology) and not really relevant to what you're trying to do here (you would choose between NetMsmqBinding vs. WsHttpBinding vs. NetTcpBinding, to name a few). You could use either polling or a duplex binding, and either would be completely valid, although the implementation would be drastically different.

To implement a polling approach, I would recommend using a session-based WCF service. Your session would last for as long as you hold onto the proxy to your WCF service in your client, and you would keep using that same proxy to get updates on your request until it finally comes back with a status of Completed. This seems fairly straightforward to implement for both the client and service.

Using a duplex service would also be a valid approach, but may be more complicated to implement if you've never worked with WCF. With a duplex service, in the definition of your ServiceContract you define a CallbackContract, which is another ServiceContract that your service uses to send messages back to the client. In your case, I think you would want 2 distinct operations in your CallbackContract, one to report back each result, and a separate one to indicate all results had been retrieved so your client knows to not expect any more results and close the channel. The MSDN documentation on Duplex services is fairly thorough, but there's definitely a bit of a learning curve with WCF.

0
votes

Since I'm just taking a stab at it I'll just give you this pointer to start looking at.

Use a Stream as your return type and use an IEnumerable while doing a return yield on each pass through your records search. If you serialize each record manually into JSON you can dump the data down the Stream.

A potential example for the client side would be to try and consume the streaming Twitter API (http://dev.twitter.com/pages/streaming_api) which would allow you to test the client side of working with a Stream and verifying the backend of your proof of concept before taking on the server side.