title: WCF (Silverlight) Duplex - Not hitting server
body: <p>I have created a web application with a Silverlight project embedded in it, using VS 2008 SP 1, and the Silverlight 3 tools, on Vista and Windows 7.</p>
  
  <p>The duplex service code:</p>
  
  <pre><code>    [ServiceContract(Namespace = "cotoco", CallbackContract = typeof(IDuplexClient))]
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  public class DuplexServer
  {
  private IDuplexClient _client;
  private string _message;
  private int _messageCounter;
  
  private Timer _timer;
  
  public DuplexServer()
  {
  }
  
  #region IDuplexServer Members
  
  [OperationContract(IsOneWay = true)]
  public void SendEcho(string message)
  {
      _client = OperationContext.Current.GetCallbackChannel&lt;IDuplexClient&gt;();
      _message = message;
  
      _timer = new Timer();
      _timer.Interval = 2000;
      _timer.Enabled = true;
      _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
      _timer.Start();
  }
  
  void _timer_Elapsed(object sender, ElapsedEventArgs e)
  {
      _client.ReturnEcho(string.Format("Duplex Echo {0}: {1}", _messageCounter, _message));
  
      _messageCounter++;
      if (_messageCounter &gt; 5)
          _timer.Dispose();
  }
  
      #endregion
  }
  
  [ServiceContract]
  public interface IDuplexClient
  {
      [OperationContract(IsOneWay = true)]
      void ReturnEcho(string message);
  }
  </code></pre>
  
  <p>The duplex config section:</p>
  
  <p>&lt;system.serviceModel&gt;
    &lt;behaviors&gt;
     &lt;serviceBehaviors&gt;
      &lt;behavior name="DuplexServerBehavior"&gt;
       &lt;serviceMetadata httpGetEnabled="true" /&gt;
       &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
      &lt;/behavior&gt;
     &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
    &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="true" /&gt;
    &lt;services&gt;
     &lt;service behaviorConfiguration="DuplexServerBehavior" name="DuplexServer"&gt;
      &lt;endpoint address="" binding="wsDualHttpBinding" contract="DuplexServer" /&gt;
      &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
     &lt;/service&gt;
    &lt;/services&gt;
   &lt;/system.serviceModel&gt;</p>
  
  <p>I have setup a Duplex service in the client application as follows: </p>
  
  <pre><code>        Binding svcBinding;
          EndpointAddress svcAddress;
  
          svcBinding = new PollingDuplexHttpBinding() { UseTextEncoding = true };
          svcAddress = new EndpointAddress("http://localhost/CTC.Test.WCF.Server/DuplexServer.svc");
          _duplex = new DuplexServerClient(svcBinding, svcAddress);
  </code></pre>
  
  <p>I have used a Simplex service in tandem with this, and calls to the Simplex service hit the breakpoints setup on the server and i can step through. </p>
  
  <p>Calls to the Duplex service do not hit the breakpoints, although no error is raised on the client. If i inspect the HTTP traffic with Fiddler, i can see hundreds of 202 requests being fired after the initial request - i assume these are the polling requests.</p>
  
  <p>Initial Duplex Request:</p>
  
  <p>POST <a href="http://localhost/CTC.Test.WCF.Server/DuplexServer.svc" rel="nofollow noreferrer">http://localhost/CTC.Test.WCF.Server/DuplexServer.svc</a> HTTP/1.1
  Accept: <em>/</em>
  Content-Length: 665
  Content-Type: application/soap+xml; charset=utf-8
  UA-CPU: x86
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; (R1 1.6); SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
  Host: cotocovista4.cotoco.local
  Connection: Keep-Alive
  Pragma: no-cache</p>
  
  <p>&lt;s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;s:Header&gt;&lt;a:Action s:mustUnderstand="1"&gt;urn:IDuplexServer/SendEcho&lt;/a:Action&gt;&lt;netdx:Duplex xmlns:netdx="http://schemas.microsoft.com/2008/04/netduplex"&gt;&lt;netdx:Address&gt;<a href="http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=ae3e3139-0df8-41eb-97db-69c2c48782b7&lt;/netdx:Address&gt;&lt;netdx:SessionId&gt;43f9e320-cde3-4e21-a748-e5b29c10ee25&lt;/netdx:SessionId&gt;&lt;/netdx:Duplex&gt;&lt;a:To" rel="nofollow noreferrer">http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=ae3e3139-0df8-41eb-97db-69c2c48782b7&lt;/netdx:Address&gt;&lt;netdx:SessionId&gt;43f9e320-cde3-4e21-a748-e5b29c10ee25&lt;/netdx:SessionId&gt;&lt;/netdx:Duplex&gt;&lt;a:To</a> s:mustUnderstand="1"&gt;<a href="http://cotocovista4.cotoco.local/CTC.Test.WCF.Server/DuplexServer.svc&lt;/a:To&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;SendEcho&gt;&lt;message&gt;Message!&lt;/message&gt;&lt;/SendEcho&gt;&lt;/s:Body&gt;&lt;/s:Envelope&amp;gt" rel="nofollow noreferrer">http://cotocovista4.cotoco.local/CTC.Test.WCF.Server/DuplexServer.svc&lt;/a:To&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;SendEcho&gt;&lt;message&gt;Message!&lt;/message&gt;&lt;/SendEcho&gt;&lt;/s:Body&gt;&lt;/s:Envelope&amp;gt</a>;</p>
  
  <p>Subsequent Duplex Requests:</p>
  
  <p>POST <a href="http://localhost/CTC.Test.WCF.Server/DuplexServer.svc" rel="nofollow noreferrer">http://localhost/CTC.Test.WCF.Server/DuplexServer.svc</a> HTTP/1.1
  Accept: <em>/</em>
  Content-Length: 588
  Content-Type: application/soap+xml; charset=utf-8
  UA-CPU: x86
  Accept-Encoding: gzip, deflate
  User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; (R1 1.6); SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618)
  Host: cotocovista4.cotoco.local
  Connection: Keep-Alive
  Pragma: no-cache</p>
  
  <p>&lt;s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;s:Header&gt;&lt;a:Action s:mustUnderstand="1"&gt;<a href="http://docs.oasis-open.org/ws-rx/wsmc/200702/MakeConnection&lt;/a:Action&gt;&lt;a:To" rel="nofollow noreferrer">http://docs.oasis-open.org/ws-rx/wsmc/200702/MakeConnection&lt;/a:Action&gt;&lt;a:To</a> s:mustUnderstand="1"&gt;<a href="http://cotocovista4.cotoco.local/CTC.Test.WCF.Server/DuplexServer.svc&lt;/a:To&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;wsmc:MakeConnection" rel="nofollow noreferrer">http://cotocovista4.cotoco.local/CTC.Test.WCF.Server/DuplexServer.svc&lt;/a:To&gt;&lt;/s:Header&gt;&lt;s:Body&gt;&lt;wsmc:MakeConnection</a> xmlns:wsmc="http://docs.oasis-open.org/ws-rx/wsmc/200702"&gt;&lt;wsmc:Address&gt;<a href="http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=ae3e3139-0df8-41eb-97db-69c2c48782b7&lt;/wsmc:Address&gt;&lt;/wsmc:MakeConnection&gt;&lt;/s:Body&gt;&lt;/s:Envelope&amp;gt" rel="nofollow noreferrer">http://docs.oasis-open.org/ws-rx/wsmc/200702/anonymous?id=ae3e3139-0df8-41eb-97db-69c2c48782b7&lt;/wsmc:Address&gt;&lt;/wsmc:MakeConnection&gt;&lt;/s:Body&gt;&lt;/s:Envelope&amp;gt</a>;</p>
  
  <p>Does anyone know why this would happen, i thought I'd finally sussed the last problem when it stopped throwing connection exceptions....</p>
  
  <p>Regards</p>
  
  <p>Tris</p>
  
  <p>Update: I have tried recreating this in the following project types: WCF Application, Web Application, Web Project. I have succeeded in implementing the MS Example that uses WCF Message's for the Duplex parameters without problem, but i was looking for a rapid way of assembling duplex web services using WSDL.</p>