Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bindingConfiguration vs bindingName

Tags:

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?

like image 421
devlife Avatar asked Sep 20 '11 20:09

devlife


People also ask

What is bindingConfiguration?

The bindingconfiguration attribute is the one which tells WCF which configuration to use.

What is HTTP binding in WCF?

BasicHttpBinding is suitable for communicating with ASP.NET Web Service (ASMX) based services that conform to the WS-Basic Profile that conforms with Web Services. This binding uses HTTP as the transport and text/XML as the default message encoding. Security is disabled by default.

What is endpoint in web config?

Endpoints provide the configuration required for the communication and create the complete WCF service application. WCF provides communication for client applications using Endpoints. Endpoints provide the configuration required for the communication and create the complete WCF service application.


2 Answers

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??)

like image 88
marc_s Avatar answered Sep 21 '22 18:09

marc_s


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

like image 44
Joel C Avatar answered Sep 19 '22 18:09

Joel C