【问题标题】:calling https wcf service from silverlight从 silverlight 调用 https wcf 服务
【发布时间】:2009-05-12 18:21:22
【问题描述】:

我正在尝试从 silverlight 访问 https wcf 服务。 clientaccesspolicy 放置在服务根目录上,我已经通过 silverlightspy 验证它显示它是有效的并且允许调用。 我能够从桌面客户端成功调用该 web 服务,但是当尝试从 silverlight 调用时,它会抛出一个错误,调用....服务失败可能是跨域策略等无效.... 有任何想法吗???? 这里也是服务跨域策略:

    <?xml version="1.0" encoding="utf-8"?>
<access-policy>  <cross-domain-access>    
<policy>
      <allow-from http-request-headers="SOAPAction">    
    <domain uri="*" />
      </allow-from> 
     <grant-to>   
     <resource include-subpaths="true" path="/" />
      </grant-to>  
  </policy>
  </cross-domain-access>
</access-policy>

【问题讨论】:

  • 没有看到跨域策略...

标签: wcf silverlight https silverlight-2.0


【解决方案1】:

您需要一个单独的域节点用于 https:

 <domain uri="https://*" />

来自这篇文章:

http://timheuer.com/blog/archive/2008/10/14/calling-secure-services-with-silverlight-2-ssl-https.aspx

【讨论】:

    【解决方案2】:

    【讨论】:

      【解决方案3】:

      如果服务和 silverlight 应用程序是从同一个网站提供的,并且您使用的是 Silverlight 4,您可以通过以下方式在没有跨域策略文件的情况下完成此操作:

      • 通过 https 访问 silverlight 应用程序
      • 使用 ServiceReferences.ClientConfig 文件中的相对地址访问服务
      • 在服务的 BasicHttpBinding 中使用传输模式安全性。

      以下是 ServiceReferences.ClientConfig 的示例:

      <configuration>
          <system.serviceModel>
              <bindings>
                  <basicHttpBinding>
                      <binding name="BasicHttpBinding_IMyService" maxBufferSize="2147483647"
                          maxReceivedMessageSize="2147483647">
                        <!--Transport mode security (setup the same way on the server):-->
                          <security mode="Transport" />
                      </binding>
                  </basicHttpBinding>
              </bindings>
              <client>
                <!--Relative address (This is the part that requires SL4):-->
                  <endpoint address="../Services/MyService.svc"
                      binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                      contract="MyApplication.MyService" name="BasicHttpBinding_IMyService" />
              </client>
          </system.serviceModel>
      </configuration>
      

      【讨论】:

        【解决方案4】:

        你看过这里吗?

        Calling WCF Service from Silverlight

        【讨论】:

        • 如果服务在https,调用者在http,有什么限制吗?
        猜你喜欢
        • 2010-09-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多