title: How to setup proxy Credentials using HttpTransportBindingElement on WCF?
body: <p>I coded a WCF Service using HttpTransportBindingElement in conjunction with IIS on port 80.
  The code works fine as long as no proxy is used. But if a customer has a http-proxy the communication between WCF-Client and Server does not work in this case by occuring following error:</p>
  
  <p><em>'There was no endpoint listening at ... that could accept the message. This is often caused by an incorrect address or SOAP action.'</em></p>
  
  <p><strong>It is essential to use settings by code ONLY!</strong></p>
  
  <p>here is my code approach for that issue but i stuck on it:</p>
  
  <pre><code>bool SendClientRequest(Action&lt;ICustomerService&gt; channel)
  {
  
    string proxy ="my.proxy.domain:8080";
    string user = "user1";
    string password="secret";
  
    // maybe i do not need this 3 lines!
    WebProxy webproxy = new WebProxy(proxy, true);
    webproxy.Credentials = new NetworkCredential(user, password);
    WebRequest.DefaultWebProxy = webproxy;
  
    CustomBinding customBinding = new CustomBinding();
    customBinding.Elements.Add(new HttpTransportBindingElement()
    {
  
     AuthenticationSchemes.None : AuthenticationSchemes.Basic,                
     ProxyAddress = string.IsNullOrEmpty(proxy) ? null : new Uri(proxy),
     UseDefaultWebProxy = false,
     BypassProxyOnLocal = true,
     TransferMode = TransferMode.Streamed,
     MaxReceivedMessageSize = 84087406592,
     MaxBufferPoolSize = 0x1000000,
     MaxBufferSize = 0x1000000
  
    });
  
  
    using (ChannelFactory&lt;ICustomerService&gt; factory = new  
    ChannelFactory&lt;ICustomerService&gt;(customBinding ))
    {
     IClientChannel contextChannel = null;
     string url = "http://my.domain.de/Distribution/eService.svc", 
     EndpointAddress ep = new EndpointAddress(url);
     ICustomerService clientChannel = factory.CreateChannel(ep);                
  
  
     contextChannel = clientChannel as IClientChannel;
     contextChannel.OperationTimeout = TimeSpan.FromMinutes(rcvTimeout );
  
     channel(clientChannel); // &lt;- here i get the exception!
     return true;
    }
  }
  </code></pre>
  
  <p>I tried several solution approaches but nothing seems to be specific like mine.</p>