0

情况:

  1. 我们有带有 IIS7 的 Windows 2008 Web 服务器,(.NET4)
  2. 我们只能通过默认的 HTTPS (443) 端口 与网络服务器通信
  3. 服务器上托管了一个 ASP.NET 网站,该服务是网站代码的一部分。
  4. 一些客户端(支持 WCF 的桌面应用程序)希望与我们的新 WCF Web 服务进行通信
  5. 双方之间的消息大小可以是 100 - 400 kb
  6. 我们希望保留 IIS 的 WCF 服务部分。
  7. 在客户端,我们请求自定义用户名和密码以连接到我们的服务
  8. 有更长的会话,后面有更多的 DB processign
  9. 并且有快速的短会话——比如来自客户端的 ping
  10. 客户端密码存储在我们的网络服务器上(来自 DB) - 客户端应根据这些密码进行身份验证。

问题
1. 从这些限制来看,最好的协议是什么?
2. 你会默认使用会话吗?
3.首先尝试了这个绑定(它可以工作,但是没有会话支持)

  <!--define a SOAP binding-->
  <wsHttpBinding>
    <binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">
      <readerQuotas maxArrayLength="102400" />
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>
  </wsHttpBinding>

要启用会话:

  <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 的会话吗?

4

2 回答 2

0
  1. wsHttpBinding,保持 http 和安全性,IIS 将管理服务的生命周期。此外,您可能需要一个专用的应用程序池。
  2. 是否使用 Session 是设计问题。如果在调用之间存在要维护的状态,则使用会话,否则每次调用都使用。ping 操作不需要会话。

我建议使用以下绑定配置以及每次调用:

  <wsHttpBinding>
    <binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">          
      <readerQuotas maxArrayLength="102400" />
      <security>
        <message clientCredentialType="Username"/>
      </security>
    </binding>
  </wsHttpBinding>

希望能帮助到你!

于 2010-06-17T13:12:05.017 回答
0

所以,最后我使用 Session 因为它没有太大的性能影响。这也是一个约束,我们应该知道如何通过网络服务与我们交谈。所以我们需要认证。

Beaud 的回答很有帮助 - 但是缺少的部分是自定义名称和密码验证器:http: //msdn.microsoft.com/en-us/library/aa702565.aspx

有了这个 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>
于 2010-06-19T16:17:08.610 回答