rest - AdapterStream never flushes properly in WCF service? -


i've written windows service application exposes wcf rest web service. call signature follows:

[operationcontract] [webinvoke(     method = "post",     uritemplate = "/render",     bodystyle = webmessagebodystyle.bare)] stream render(stream input); 

it's implemented so:

public stream render(stream input) {     return new adapterstream(output => doactualwork(input, output)); } 

but when render() returns, underlying stream calling client cut off, gets http 200 ok , 0 bytes of body data. after that, breakpoint inside doactualwork() hit - server job , dumps data onto adapterstream during following seconds, caller has been disconnected , long gone.

any ideas why happens? since doactualwork() called, seem framework did try fetch data adapterstream, ... well, late or something.

if nothing else, have other suggestions achieving same thing (i.e. circumventing fact result stream return value rather method parameter) without having dump (huge) results memorystream first , returning that? works charm, way, except eating lots of memory.

even if question quite old, solved problem this:

first ensure webhttpbinding has transfermode streamed. second ensure flush , dispose stream given in callback. third block callback (not render method!) until finished writing stream.


Comments