我正在尝试使用2种不同的basicHttpBinding配置来设置服务。我知道我必须为它们创建单独的端点(这没有问题)。目标是将1个basicHttpBinding端点配置为使用Windows Auth(我们公司的默认设置),并将一个basicHttpBinding端点配置为使用基本的http auth。这是一个绑定配置:
<!-- Normal configuration with Windows Auth -->
<basicHttpBinding>
<binding maxBufferPoolSize="4194304" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
这是第二种配置:
<!-- Configuration with basic authentication -->
<basicHttpBinding>
<binding maxBufferPoolSize="4194304" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
是否有名称属性或我可以用来区分这两者的东西?
答案 0 :(得分:1)
在WCF配置中,为每个绑定指定唯一名称,然后在服务端点部分引用绑定名称。以下代码段提供了一个简单的示例:
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingWindowsCredential" ... >
...
</binding>
<binding name="basicHttpBindingBasicCredential" ... >
...
</binding>
<services>
<service ... >
<endpoint ... binding="basicHttpBinding" bindingConfiguration="basicHttpBindingWindowsCredential" >
<endpoint ... binding="basicHttpBinding" bindingConfiguration="basicHttpBindingBasicCredential" >