【问题标题】:How to protect the connection to WCF service? Silverlight consuming WCF service with WsHttpBinding.如何保护与 WCF 服务的连接? Silverlight 通过 WsHttpBinding 使用 WCF 服务。
【发布时间】:2012-05-21 07:58:23
【问题描述】:

我被分配开发应该使用 WCF 服务的 silverlight 应用程序。该服务仅使用 WsHttpBinding 公开端点。

据我了解,在 silverlight 应用程序中无法使用此服务(WsHttpBinding 是否需要特殊的操作系统支持?)。

对服务的每次调用都包含用户凭据作为参数。

这是生成服务的配置如何查找 .Net 4 应用程序:

<system.serviceModel>
    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IScheduleService" 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="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <client>
        <endpoint address="blahblah/Service.svc/ws"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IScheduleService"
            contract="ScheduleService.IScheduleService" name="WSHttpBinding_IScheduleService">
            <identity>
                <dns value="localhost" />
            </identity>
        </endpoint>
    </client>
</system.serviceModel>

对不起,介绍太长了,问题来了。

Silverlight 世界中保护与 WCF 服务的连接的常见方法是什么? 如何更改服务,以供silverlight客户端使用?

【问题讨论】:

    标签: .net wcf silverlight security wshttpbinding


    【解决方案1】:

    最常见的方法是使用传输安全 (ssl) - 就像您使用此设置一样。这里唯一的问题可能是 wshttpbinding 期望客户端 soap 消息包含 silverlight 可能不支持的 ws-addressing 标头(使用 fiddler 或 wcf 日志记录检查)。

    我会说 - 如果您能够将服务更改为 basicHttpBinding,那是最好的。否则,您仍然可以这样做,但您需要手动将标头推送到肥皂消息中。编写一个工作肥皂客户端(winforms)并查看它发送的肥皂的外观。然后使用message inspector on silverlight添加它。

    【讨论】:

      猜你喜欢
      • 2012-08-31
      • 2017-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多