title: WCF duplex channel, de-coupling the request and the response
body: <p>I'm contemplating a project where I'll be required to make use of what is variously called the "asynchronous" mode, or the "duplex" mode, or the "callback" mode of SOAP webservice. In this mode, the caller of the service provides in the SOAP header a "reply-to" address, and the service, instead of returning the output of the call in the HTTP response, creates a separate HTTP connection to this "reply-to" address and posts the response message to it. This is normally achieved in WCF using a CompositeDuplexBinding, like so:</p>
  
  <pre><code>&lt;binding name="async_http_text"&gt;
      &lt;compositeDuplex clientBaseAddress="http://192.168.10.123:1234/async" /&gt;
      &lt;oneWay /&gt;
      &lt;textMessageEncoding messageVersion="Soap12WSAddressing10" /&gt;
      &lt;httpTransport useDefaultWebProxy="false" /&gt;
  &lt;/binding&gt;
  </code></pre>
  
  <p>This results in not one, but two HTTP connections per call: one from the client to the service, and then one from the service back to the client. From the point of view of the service implementation, nothing changes, you have a method that implements the interface method, and you take in the request and return the response. Fantastic, this is what I need, almost.</p>
  
  <p>In my situation, the request and response can be separated by anything from minutes to days. I need a way to decouple the request and the response, and "store" the state (message, response URI, whatever) until I have enough information to respond at a later time (or even never, under certain circumstances).</p>
  
  <p>I'm not terribly excited about having my methods essentially "paused" for up to days at a time, along with the required silly timeout values (if they're even accepted as valid), but I don't know how to go about putting a system like this together.</p>
  
  <p>In order to be completely clear, I'm implementing a set of standards provided by a standards body, so I do not have flexibility to change SOAP message semantics or alter protocol implementations. This sort of interaction is exactly what was intended when the ReplyTo header was implemented in WS-Addressing.</p>
  
  <p>How would you do it? Perhaps Workflow Foundation enables this sort of thing?</p>