title: Adding a service reference to a WCF service with webHttpBinding and security mode Transport results in an incorrect config file
body: <p>I have searched and searched and I cannot find a solution.  It seems like it would be relatively common to run into this... WCF REST service over https.  When I add the service reference all of the proxy classes are correct and I can create the objects defined in the service, call the services, etc.  However, I can't create a configured client with the proxy's client classes.  I have to explicity create the bindings, behaviors, and endpoints and add them to the client.  FOr example, what I should be able to do, based on all of my research is:</p>
  
  <pre><code>ServiceClient = new ServiceClient();
  </code></pre>
  
  <p>And be off and running.  However, what I have to do is:</p>
  
  <pre><code>WebHttpBinding serviceBinding = new WebHttpBinding(WebHttpSecurityMode.Transport);
  serviceBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
  EndpointAddress endPointAddress
              = new EndpointAddress(&lt;endpointaddress&gt;);
  
  // Create Service Client 
  ServiceClient = new ServiceClient(serviceBinding, endPointAddress);
  
  // Add Web Behavior to the EndPoint
  WebHttpBehavior webHttpBehavior = new WebHttpBehavior();
  ServiceClient.Endpoint.Behaviors.Add(webHttpBehavior);
  
  // Set up the request to POST with a wrapped request
  WebInvokeAttribute postAttribute = new WebInvokeAttribute();
  postAttribute.Method = "POST";
  postAttribute.BodyStyle = WebMessageBodyStyle.WrappedRequest;
  ServiceClient.Endpoint.Contract.Operations.Find(&lt;operationname&gt;).Behaviors.Add(postAttribute);
  </code></pre>
  
  <p>In order to mimic the service configuration:</p>
  
  <pre><code>&lt;behaviors&gt;
        &lt;endpointBehaviors&gt;
          &lt;behavior name="AspNetAjaxBehaviorXml"&gt;
            &lt;webHttp /&gt;
          &lt;/behavior&gt;
        &lt;/endpointBehaviors&gt;
         &lt;serviceBehaviors&gt;
            &lt;behavior name="AuthenticationServicesBehavior"&gt;
              &lt;serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" /&gt;
              &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;/behavior&gt;
            &lt;behavior name="LoggingServicesBehavior"&gt;
               &lt;serviceMetadata httpsGetEnabled="true" policyVersion="Policy15" /&gt;
               &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
            &lt;/behavior&gt;
         &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment aspNetCompatibilityEnabled="True" /&gt;
      &lt;bindings&gt;
        &lt;webHttpBinding&gt;
          &lt;binding name="WebSslBinding"&gt;
            &lt;security mode="Transport"&gt;
              &lt;transport clientCredentialType="None" /&gt;
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/webHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;services&gt;
         &lt;service behaviorConfiguration="AuthenticationServicesBehavior"
            name="AuthenticationServices"&gt;
            &lt;endpoint address="authenticate" behaviorConfiguration="AspNetAjaxBehaviorXml"
               binding="webHttpBinding" bindingConfiguration="WebSslBinding"
               name="AuthenticationEndPoint" bindingNamespace="&lt;mynamespace&gt;"
               contract="IService" /&gt;
         &lt;/service&gt;
  </code></pre>
  
  <p></p>
  
  <p>The "Add Service Reference" is giving me this:</p>
  
  <pre><code>&lt;bindings&gt;
     &lt;customBinding&gt;
      &lt;binding name="AuthenticationEndPoint"&gt;
       &lt;!--    WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'EchoAppsServices':    --&gt;
       &lt;!--    &lt;wsdl:binding name='AuthenticationEndPoint'&gt;    --&gt;
       &lt;!--        &lt;sp:HttpsToken xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"&gt;..&lt;/sp:HttpsToken&gt;    --&gt;
       &lt;textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
        messageVersion="Soap12" writeEncoding="utf-8"&gt;
        &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
         maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
       &lt;/textMessageEncoding&gt;
      &lt;/binding&gt;
     &lt;/customBinding&gt;
    &lt;/bindings&gt;
    &lt;client&gt;
     &lt;endpoint binding="customBinding" bindingConfiguration="AuthenticationEndPoint"
      contract="AuthenticationService"
      name="AuthenticationEndPoint" /&gt;
    &lt;/client&gt;
  </code></pre>
  
  <p>I believe my inability to create a default client that works out of the box is related to the problem with WsdlImporter.  I get a similar error when I use svcutil:</p>
  
  <pre><code>Warning: The following Policy Assertions were not Imported:
    XPath://wsdl:definitions[@targetNamespace='&lt;mynamespace&gt;']/wsdl:binding[@na
  me='AuthenticationEndPoint']
    Assertions:
      &lt;sp:HttpsToken xmlns:sp='http://schemas.xmlsoap.org/ws/2005/07/securitypolic
  y'&gt;..&lt;/sp:HttpsToken&gt;
  </code></pre>
  
  <p>I'm sure it has something to do with my self signed cert, but I can't get makecert to give me a functioning cert with a CA that doesn't cause my IIS to crash.</p>
  
  <p>Environment details:
  VS2008
  XP 64bit
  .NET 3.5
  IIS6</p>
  
  <p>Thanks in advance for any help...</p>