我有一组IIS7 7托管的net.tcp WCF服务,它们为我的ASP.NET MVC web应用程序提供服务。网络应用程序是通过互联网访问的。
WCF Services (IIS7) <--> ASP.NET MVC Application <--> Client Browser
这些服务是经过用户名验证的,客户端(我的web应用程序)使用的帐户最终成为主机上的当前主体。
我希望对其中一个服务进行不同的身份验证,因为它为我的登录视图提供了视图模型。当它被调用时,客户端显然还没有登录。我认为,如果服务驻留在与web应用程序不在同一域中的机器上,Windows身份验证可以提供最好的、或者仅仅是基于证书的安全性(实际上,我也应该使用这种安全性)。
但这不是重点。使用多个TCP绑定会给我带来麻烦。我尝试在我的客户端配置中这样设置它:
<bindings>
<netTcpBinding>
<binding>
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
<binding name="public">
<security mode="Transport">
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint contract="Server.IService1" binding="netTcpBinding" address="net.tcp://localhost:8081/Service1.svc"/>
<endpoint contract="Server.IService2" binding="netTcpBinding" bindingConfiguration="public" address="net.tcp://localhost:8081/Service2.svc"/>
</client>
服务器配置如下:
<bindings>
<netTcpBinding>
<binding portSharingEnabled="true">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
</security>
</binding>
<binding name="public">
<security mode="Transport">
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service name="Service1">
<endpoint contract="Server.IService1, Library" binding="netTcpBinding" address=""/>
</service>
<service name="Service2">
<endpoint contract="Server.IService2, Library" binding="netTcpBinding" bindingConfiguration="public" address=""/>
</service>
</services>
<serviceHostingEnvironment>
<serviceActivations>
<add relativeAddress="Service1.svc" service="Server.Service1"/>
<add relativeAddress="Service2.svc" service="Server.Service2"/>
</serviceActivations>
</serviceHostingEnvironment>
问题是,这两个绑定似乎不希望一起生活在我的主机。当我移除它们中的任何一个时,这一切都很好,但是它们一起在客户机上产生了以下异常:
“net.tcp://localhost:8081/Service2.svc”不支持请求的升级。这可能是由于不匹配的绑定(例如,在客户端而不是服务器上启用了安全性)。
在服务器跟踪日志中,我发现以下异常:
协议类型应用程序/协商被发送到不支持该类型升级的服务。
我是在寻找正确的方向,还是有更好的方法来解决这个问题?
更新
虽然这个问题似乎相当古老,但它仍然与我有关(我也认为对其他人也是如此)。目前,我正在使用一个神奇的用户名/密码组合(因为当前的主体需要一个用户名)来访问不应该首先进行身份验证的服务。根据这个问题,您可以看到,我更希望有一个专门针对这些公共服务的未经身份验证的绑定。在这种情况下,一个神奇的帐户是不不安全的,它不提供任何访问,除了在公共层面。
发布于 2012-07-19 11:07:09
尝试启用服务使用多个绑定:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />发布于 2010-04-23 20:53:00
我认为您需要使用'bindingConfiguration‘属性来为每个服务端点指定要使用的绑定配置。
https://stackoverflow.com/questions/2701502
复制相似问题