An IObservable pushes results at you. You can't tell when an IObservable will end, only that it has. This is their nature.
There is no reason for you to serialize the interface itself.
I'm a bit confused about what you are expecting this method to return - you mention you are expecting an enumerable (i.e. IEnumerable
?) making this a request/response call with a single result. If this is the case, you can use Observable.FromAsyncPattern
to easily create a IObservable for the result.
If, however, the results will be pushed individually from the Server over a Stream or via a Callback, then you can just create a wrapper via Observable.Create that initiates the connection/request on Subscribe and pushes results out via OnNext as they come back, and have the Dispose close the stream etc.
Essentially either way, you are creating a proxy on the client side that exposes a regular WCF client through a locally created IObservable
interface. This is pretty much how all IObservable
services work.
If on the server side you have an IObservable to return, you'll need to do the reverse there - translate a regular client side call into a subscription against the IObservable from which you send results back to the client via regular WCF Streams or Callbacks.