如何在IIS7中配置WCF服务:HTTPS、会话、wsHttpBinding(SOAP)
情况:如何在IIS7中配置WCF服务:HTTPS、会话、wsHttpBinding(SOAP),wcf,session,c#-4.0,wshttpbinding,Wcf,Session,C# 4.0,Wshttpbinding,情况: 我们有带IIS7的windows2008web服务器(.NET4) 我们只能通过默认的HTTPS(443)端口与Web服务器通信 服务器上有一个ASP.NET网站,该服务是网站代码的一部分 一些客户端(支持WCF的桌面应用程序)希望与我们新的WCF Web服务通信 双方之间的消息大小可以是100-400 kb 我们希望保留IIS的WCF服务部分 在客户端,我们请求自定义用户名和密码以连接到我们的服务 有更长的会话,后面有更多的数据库处理 还有一些快速的短会话,比如客户端的ping 客户端
1.根据这些限制条件,最好使用什么协议?
2.您会默认使用会话吗?
3.首先尝试了此绑定(它可以工作,但是没有会话支持)
要启用会话,请执行以下操作:
<wsHttpBinding>
<binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">
<readerQuotas maxArrayLength="102400" />
<reliableSession enabled="true" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic" />
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
我的感觉是,这种传输和消息安全性太高了——我的意思是,为了允许使用wsHttpBinding的会话,我们真的需要这种安全性吗
<wsHttpBinding>
<binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">
<readerQuotas maxArrayLength="102400" />
<security>
<message clientCredentialType="Username"/>
</security>
</binding>
</wsHttpBinding>
希望有帮助 所以,最后我使用Session,因为它没有太大的性能影响。这也是一个限制,我们应该知道如何通过Web服务与我们交谈。所以我们需要认证 Beaud的回答帮助很大-但是缺少的是自定义名称和密码validaror: 使用此web.config:
<wsHttpBinding>
<binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">
<readerQuotas maxArrayLength="102400"/>
<reliableSession enabled="true"/>
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Basic"/>
<message clientCredentialType="UserName"/>
</security>
</binding>
</wsHttpBinding>
也许这对某人有帮助
当发现这些神奇的WCF配置问题时,WCF跟踪也是一个很大的帮助:
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="SdrConfigExample.e2e"/>
</listeners>
</source>
</sources>
</system.diagnostics>
谢谢!1.是的,关于应用程序池,我也有同样的想法。所以在主网站下有一个专门的应用程序。2.所以会话。。。拥有它们会很好,因为有几个不同的请求需要自动处理。当会话处于活动状态时,我不需要每次都转到DB。所以问题仍然存在——第二个“DefaultSOAPBasedHTTPSBinding”可以简化吗?使用IIS托管:配置“”会产生什么样的影响?只有您知道是否最好点击数据库或实例来管理资源,但需要管理会话。。。如果我是你,我就不会用它们。顺便说一下,在没有会话的情况下仍然可以进行身份验证。
<system.diagnostics>
<trace autoflush="true"/>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="sdt" type="System.Diagnostics.XmlWriterTraceListener" initializeData="SdrConfigExample.e2e"/>
</listeners>
</source>
</sources>
</system.diagnostics>