wcfsslwcf-hosting

WCF Service over HTTPS giving errors


I have made a WCF service with configuration as follows:

  <!-- This is the binding for SSL-->
  <wsHttpBinding>
    <binding name="SSLBinding">
      <security mode="Transport" >
        <transport clientCredentialType="None" ></transport>            
      </security>
    </binding>       
  </wsHttpBinding>  
  <!-- SSL Binding Ends here.-->

</bindings>

<behaviors>
  <serviceBehaviors>

    <!-- This is the behavior we have defined for SSL configuration-->
    <behavior name="SSLBehavior">
      <serviceMetadata httpsGetEnabled="True"/>          
    </behavior>
    <!-- SSL Behavior Ends here -->        
  </serviceBehaviors>
</behaviors>

<services>
  <!-- Service configured alongwith its Mex Endpoint-->      
  <service name="CalculatorService.Service1" behaviorConfiguration="SSLBehavior">
    <endpoint contract="CalculatorService.IService1" name="SSLAddress" binding="wsHttpBinding"  bindingConfiguration="SSLBinding"></endpoint>
    <endpoint name="mex"  binding="mexHttpsBinding" contract="IMetadataExchange"></endpoint>
  </service> 

</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false" />

I have used the following tutorial to host SSL on WCF service on IIS 5.1 http://www.codeproject.com/Articles/36705/7-simple-steps-to-enable-HTTPS-on-WCF-WsHttp-bindi

I am getting the error as

A binding instance has already been associated to listen URI 
'https://wd-xpa7kyy12d3.XXXX.com/CalculatorService/Service1.svc'. If two endpoints want to share the same ListenUri, they must also share the same binding object instance. The two conflicting endpoints were either specified in AddServiceEndpoint() calls, in a config file, or a combination of AddServiceEndpoint() and config. 

In endpoint named "SSLAddress" I added "address" as 'https://wd-xpa7kyy12d3.XXXX.com/CalculatorService/Service1.svc', but was not able to add service reference with this URL, and had to specifically give WSDL path.

Even after providing WSDL path and adding service reference successfully to console application, when the client proxy was executing the methods, it was giving error. So I removed the address attribute from endpoint and now this issue is coming. I am not sure what is wrong in current configuration? Thanks for help.


Solution

  • try adding

    address="mex"
    

    to your meta data endpoint. the address specified ends up being a relative path, so it will be given

    https://wd-xpa7kyy12d3.XXXX.com/CalculatorService/Service1.svc/mex
    

    as an address. The other endpoint will remain at

    https://wd-xpa7kyy12d3.XXXX.com/CalculatorService/Service1.svc