0

Suppose I wanted to create a WCF WebHTTP service ("ServiceREST") that had a reference to a duplex service ("ServiceDuplex"). ServiceDuplex requires implementations of certain callback members to deliver data that is requested from it. For example, a call to GetCustomers on ServiceDuplex triggers a method on that service that serves the customers back to the client via a callback "ReceiveCustomers".

That being said, suppose I wanted a method "GetSingleCustomer" on ServiceREST. Assuming all data is being retrieved on demand (rather than caching after startup), I'd have to first call "GetCustomers" from ServiceDuplex and wait for my collection to be filled inside of the callback I implement before I can search for the single customer I need.

Since webHttp doesn't support callbacks to the client, I'm forced to use something like an AutoResetEvent inside of my GET (GetSingleCustomer) call until the duplex's callback fills the collection.

Is there a "best practice" for what I'm trying to do, or is what I'm trying to do so wrong that such a practice hasn't been created?!

Thanks for the help.

Thelonias
  • 2,918
  • 3
  • 29
  • 63

1 Answers1

0

Keep It Simple, the ServiceDuplex is not doing what is supossed to do, like make the calls Async, then why use it in the first place... just stick to only REST.

Andresps2
  • 160
  • 1
  • 2
  • 10
  • I don't really have a choice to stick to only REST. The ServiceDuplex already exists and I need data from it. Also, why is the ServiceDuplex "not doing what it is supposed to do"? – Thelonias Oct 26 '11 at 12:39
  • A duplex channel is made to get an Async behavior in our methods, chaining it with a REST service is really an overload, it adds time to get the response and nullifies the Async calls as you'll need to make them synchronous for the REST service, I'll do it only as a last resource, but it's just my opinion. – Andresps2 Oct 26 '11 at 13:54
  • I've worked with duplex OR REST for a while, in my company we have a big project that uses duplex and my task was to make a small iOS client, we had two choices, to integrate both systems, or create just the REST with the business logic from zero, the last one was our choice and it works very nice, but it was a small client, it's different if we have to rewrite the 100% of the duplex service. My 2 cents. – Andresps2 Oct 26 '11 at 14:11