devlife
devlife

Reputation: 16145

bindingConfiguration vs bindingName

What exactly is the difference between bindingConfiguration and bindingName elements in a WCF endpoint element? The reason that I ask is I am creating an endpoint which uses basicHttpBinding and SSL. I configured the web.config like this:

<basicHttpBinding>
<binding name="basicHttps">
  <security mode="Transport">
    <transport clientCredentialType="None"/>
  </security>
</binding>

<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttps" contract="Hsp.Services.Interface.Catalog.ICatalogService" address="" />

However, when using bindingConfiguration then https isn't working. When I change bindingConfiguration to bindingName it works as expected. So, what exactly is the difference between the two?

Upvotes: 21

Views: 29175

Answers (4)

Sonu Rajpoot
Sonu Rajpoot

Reputation: 505

bindingConfiguration A string that specifies the binding name of the binding to use when the endpoint is instantiated. The binding name must be in scope at the point the endpoint is defined. The default is an empty string.

This attribute is used in conjunction with binding to reference a specific binding configuration in the configuration file. Set this attribute if you are attempting to use a custom binding. Otherwise, an exception may be thrown.

bindingName A string that specifies the unique qualified name of the binding for definition export through WSDL. The default is an empty string.

Upvotes: -1

kroonwijk
kroonwijk

Reputation: 8400

Your service configuration binding is incorrect. So when you correctly refer to your binding configuration using the bindingConfiguration attribute, your service is not working. When you use the bindingName attribute, which is an invalid used attribute in your case, the service just starts a basicHttpBinding without looking at your custom configuration, which seems to work correctly.

For the different between the two elements look at: http://msdn.microsoft.com/en-us/library/ms731320.aspx.

So, using the bindingConfiguration attribute is the only correct thing. Now we still need to look at what is wrong with you binding configuration itself :-) See the following example to extract your relevant information from.

<system.web.extensions>
  <scripting>
    <webServices>
      <authenticationService enabled="true" 
         requireSSL = "true"/>
    </webServices>
  </scripting>
</system.web.extensions>
<system.serviceModel>
  <services>
    <service name="System.Web.ApplicationServices.AuthenticationService"
        behaviorConfiguration="AuthenticationServiceTypeBehaviors">
      <endpoint contract=
        "System.Web.ApplicationServices.AuthenticationService"
        binding="basicHttpBinding"
        bindingConfiguration="userHttps" 
        bindingNamespace="http://asp.net/ApplicationServices/v200"/>
      </service>
  </services>
  <bindings>
        <basicHttpBinding>
            <binding name="userHttps">
                <security mode="Transport" />
            </binding>
        </basicHttpBinding>
  </bindings>
  <behaviors>
    <serviceBehaviors>
      <behavior name="AuthenticationServiceTypeBehaviors">
        <serviceMetadata httpGetEnabled="true"/>
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment 
    aspNetCompatibilityEnabled="true"/>
</system.serviceModel>

See http://msdn.microsoft.com/en-us/library/bb398990.aspx for more details.

Upvotes: 8

Joel C
Joel C

Reputation: 5567

From the MSDN documentation

bindingConfiguration: A string that specifies the binding name of the binding to use when the endpoint is instantiated. The binding name must be in scope at the point the endpoint is defined. The default is an empty string. This attribute is used in conjunction with binding to reference a specific binding configuration in the configuration file. Set this attribute if you are attempting to use a custom binding. Otherwise, an exception may be thrown.

bindingName: A string that specifies the unique qualified name of the binding for definition export through WSDL. The default is an empty string.

I've never used bindingName, but it seems to only affect the WSDL generated for your endpoint. If something isn't working when you use bindingConfiguration="basicHttps", then it sounds like you have a misconfiguration that's preventing it from working correctly (if no bindingConfiguration is specified, the defaults will be applied, which is what's happening when you change bindingConfiguration to bindingName). I don't think <transport clientCredentialType="None"/> is valid, the possible values are Basic, Certificate, Digest, Windows, or NTLM. See Transport Security Overview

Upvotes: 8

marc_s
marc_s

Reputation: 754478

The binding= attribute just defines, which binding (protocol) you want - basicHttpBinding, wsHttpBinding, netTcpBinding etc.

Those bindings all have system default values - if you don't specify any binding configuration, those system defaults will be used.

What you've defined in your <bindings> section of your config is a binding configuration - a set of parameters for your binding of choice that will be used instead of the system defaults.

So the binding= and the bindingConfiguration= need to match - you cannot define one binding (e.g. basicHttpBinding) but then assign a binding configuration for a different binding.

That however still doesn't explain why your https doesn't work - that must be some other problem. Can you elaborate a bit more? How does it not work? Just no response, or do you get an error (if so: what is that error??)

Upvotes: 24

Related Questions