如何在 IIS7 中配置 WCF 服务:HTTPS、Sessions、wsHttpBinding (SOAP)

发布于 2024-09-05 17:04:43 字数 1535 浏览 3 评论 0原文

情况:

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

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

The situation:

  1. We have Windows 2008 web serverse with IIS7, (.NET4)
  2. We can comminicate with the webserver only through the default HTTPS (443) port
  3. There is an ASP.NET website hosted on the servers, the service is part of the website code.
  4. Some clients (desktop applications with WCF support) want to communicate with our new WCF webservice
  5. Message size between the parties can be 100 - 400 kb
  6. We'd like to keep the WCF service part of the IIS.
  7. On client side we request a custom username and password to connect to our service
  8. There are longer sessions with more DB processign behind
  9. And there are quick short sessions - like ping from the client
  10. The client passwords are stored on our webserver (from DB) - clients should be authenticated against these passwords.

Question:
1. From these constraints what would be the best protocol to use?
2. Would you use sessions by default?
3. Tried this binding first (it works, however there is no session support)

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

To enable sessions:

  <wsHttpBinding>
    <binding name="DefaultSOAPBasedHTTPSBinding" maxReceivedMessageSize="400000">          
      <readerQuotas maxArrayLength="102400" />
      <reliableSession enabled="true" />
      <security mode="TransportWithMessageCredential">
        <transport clientCredentialType="Basic" />
        <message clientCredentialType="Certificate"/>
      </security>
    </binding>
  </wsHttpBinding>

My feeling is that this transport & message securtiy is too much - I mean do we really need this in order to allow sessions with wsHttpBinding?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

超可爱的懒熊 2024-09-12 17:04:43
  1. wsHttpBinding,保留 http 和安全性,IIS 将管理服务的生命周期。此外,您可能需要一个专用的应用程序池。
  2. 是否使用 Session 是设计问题。如果调用之间需要维护状态,则使用会话,否则每次调用都使用。 ping 操作不需要会话。

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

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

希望有帮助!

  1. wsHttpBinding, stay with http and security and IIS will manage the service's life cycle. Also, you might want a dedicated application pool.
  2. Using Session or not is matter of design. Use Sessions if there is a state to maintain between the calls otherwise use per call. A ping operation wouldn't require Sessions.

I suggest the following binding configuration along with per call:

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

Hope it helps!

护你周全 2024-09-12 17:04:43

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

博德的回答很有帮助 - 然而缺少的是自定义名称和密码验证器:
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>

So, finally I use Session because it hasn't got too big performance impact. And it was also a constrain that we should know how is talking to us via the webservice. So we need authentication.

Beaud's answer helped a lot - however the missing piece was the custom name and password validaror:
http://msdn.microsoft.com/en-us/library/aa702565.aspx

With this 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>

Maybe it helps somebody...

And the WCF tracing is also a big help when finding these magic WCF configuration issues:

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文