问题描述
我最近在 Windows Server 2008 上运行 IIS 7.5 的开发 Web 服务器上安装了 4.5 框架.安装后,两个 Web 服务开始出现相同的错误.这些 Web 服务是使用 MS REST Starter Kit 构建的.这是我遇到的错误.
I'm recently installed the 4.5 framework on our development web server which runs IIS 7.5 on Windows Server 2008. After installation, two web services started having the same error. These web services were built using the MS REST Starter Kit. Here is the error I'm getting.
一个绑定实例已经与侦听 URI 相关联.如果两个端点想要共享同一个 ListenUri,它们也必须共享同一个绑定对象实例.两个冲突的端点要么在 AddServiceEndpoint() 调用中指定,要么在配置文件中指定,要么在 AddServiceEndpoint() 和配置的组合中指定.
这是我们配置文件的 system.service 模型部分的副本.
Here is a copy of the system.service model section of our config file.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<webHttpBinding>
<binding>
<security mode="Transport" />
</binding>
</webHttpBinding>
<wsHttpBinding>
<binding name="EnterpriseIdentityBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text"
textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="https://betaapps/EnterpriseIdentity/V1/UserService.svc"
binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
contract="UserServiceWCF.IUserService" name="wsSecureUsers" />
<endpoint address="https://betaapps/EnterpriseIdentity/V1/RoleService.svc"
binding="wsHttpBinding" bindingConfiguration="EnterpriseIdentityBinding"
contract="RoleServiceWCF.IRoleService" name="wsSecureRoles" />
</client>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceAuthorization principalPermissionMode="Custom">
<authorizationPolicies>
<add policyType="Hsmv.Web.Security.IdentityModel.HttpContextWithRolesPolicy, Hsmv.Web.Security" />
</authorizationPolicies>
</serviceAuthorization>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
知道为什么在安装 .Net 4.5 后会出现这个错误吗?
Any idea why this error would occur after installing .Net 4.5?
我想补充一点,我尝试删除此部分,没有它也能正常工作.
I would like to add that I tried removing this section and it does work without it.
<webHttpBinding>
<binding>
<security mode="Transport" />
</binding>
</webHttpBinding>
我使用它是因为此服务在 ssl 上运行.我听说 WCF 4.5 尝试为您创建绑定和端点,因此它们不需要在 web.config 中.所以我想知道这个部分是不是由WCF自动构建的,不需要.还是我的想法不正确?谢谢!
I use this because this service runs on ssl. I heard that WCF 4.5 tries to create bindings and endpoints for you so they don't need to be in the web.config. So I wondered if this section is being automatically built by WCF and is not needed. Or is my thinking incorrect?Thanks!
推荐答案
我来自 WCF 团队.感谢您报告此问题.WCF 团队将继续调查此问题以进行修复.在我们调查期间,您可以通过在配置文件中显式配置 webHttp 端点来解决此问题.服务将与以前的行为相同.尝试遵循这些简单的步骤.
I am from WCF team. Thanks for reporting this issue. WCF team will continue to investigate this issue for fix. While we investigate you can work around this by explicitly configuring a webHttp endpoint in your configuration file. Service will be the same by behavior like before. Try to follow these simple steps.
(我以你在这篇文章中发布的配置文件为起点)
(I am taking the configuration file that you have published in this post as a starting point)
注释掉<standardEndpoints>配置文件中的标签:
Comment out the <standardEndpoints> tag in your configuration file:
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>-->
<!--<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>-->
将此端点行为添加到您的列表中,如下所示:
Add this end point behavior to your list like this:
<端点行为>
<行为名称="REST">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</行为>
</endpointBehaviors>
</行为>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp helpEnabled="true" automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
像这样在配置文件中显式配置您的服务端点.对于突出显示的属性值,分别替换您的服务类型名称和合同名称(注意:如果您没有为服务定义合同,则在合同中插入服务类型名称="")
Explicitly configure your service endpoint in the config file like this. For highlighted attribute values substitute your service type name and contract name respectively (Note: if you don’t have a contract defined for service, then insert service type name in contract="" too)
<服务名称="WcfRestService1.Service1">
<endpoint address="" binding="webHttpBinding" contract="WcfRestService1.Service1" behaviorConfiguration="REST"/>
</服务>
</服务>
<services>
<service name="WcfRestService1.Service1">
<endpoint address="" binding="webHttpBinding" contract="WcfRestService1.Service1" behaviorConfiguration="REST" />
</service>
</services>
这篇关于WCF - .Net 4.5 安装后端点冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!