在WCF端点元素中bindingConfiguration和bindingName元素之间究竟有什么区别?我问的原因是我正在创建一个使用basicHttpBinding和SSL的端点.我像这样配置了web.config:
<basicHttpBinding>
<binding name="basicHttps">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
Run Code Online (Sandbox Code Playgroud)
<endpoint binding="basicHttpBinding" bindingConfiguration="basicHttps" contract="Hsp.Services.Interface.Catalog.ICatalogService" address="" />
Run Code Online (Sandbox Code Playgroud)
但是,使用bindingConfiguration时,https无法正常工作.当我将bindingConfiguration更改为bindingName时,它按预期工作.那么,这两者究竟有什么区别?
mar*_*c_s 23
该binding=属性只定义,它结合(协议),你想要的- ,,basicHttpBinding 等.wsHttpBindingnetTcpBinding
这些绑定都具有系统默认值 - 如果您未指定任何绑定配置,则将使用这些系统默认值.
您在<bindings>配置部分中定义的是绑定配置 - 一组用于选择绑定的参数,而不是系统默认值.
所以匹配binding=的bindingConfiguration=需要 - 你不能定义一个绑定(例如basicHttpBinding),但随后为不同的绑定分配绑定配置.
然而,这仍然无法解释为什么你的https不起作用 - 这一定是其他一些问题.你能详细说明一下吗?它怎么行不通?只是没有回应,或者你得到一个错误(如果是这样的话:那个错误是什么?)
bindingConfiguration:一个字符串,指定在实例化端点时要使用的绑定的绑定名称.绑定名称必须在定义端点的范围内.默认值为空字符串.此属性与绑定结合使用,以引用配置文件中的特定绑定配置.如果您尝试使用自定义绑定,请设置此属性.否则,可能会抛出异常.
bindingName:一个字符串,它指定通过WSDL导出定义的绑定的唯一限定名称.默认值为空字符串.
我从未使用过bindingName,但它似乎只影响为您的端点生成的WSDL.如果当您使用的东西,不工作bindingConfiguration="basicHttps",那么它听起来就像你有问题,导致其无法正常工作配置错误(如果没有bindingConfiguration指定,默认值将被应用,这是当你改变发生的事情bindingConfiguration来bindingName).我认为<transport clientCredentialType="None"/>无效,可能的值是Basic,Certificate,Digest,Windows或NTLM.请参阅传输安全概述
您的服务配置绑定不正确.因此,当您使用bindingConfiguration属性正确引用绑定配置时,您的服务无法正常工作.当您使用bindingName属性(在您的情况下是一个无效的used属性)时,该服务只是启动basicHttpBinding而不查看您的自定义配置,这似乎正常工作.
有关这两个元素之间的不同,请查看:http://msdn.microsoft.com/en-us/library/ms731320.aspx.
因此,使用bindingConfiguration属性是唯一正确的事情.现在我们仍然需要查看绑定配置本身有什么问题:-)请参阅以下示例以从中提取相关信息.
<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>
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅http://msdn.microsoft.com/en-us/library/bb398990.aspx.
| 归档时间: |
|
| 查看次数: |
24822 次 |
| 最近记录: |