【问题标题】:Error on Silverlight WCF access via https通过 https 访问 Silverlight WCF 时出错
【发布时间】:2011-10-01 19:00:25
【问题描述】:

来自我的 silverlight 4.0 应用程序。我可以轻松访问 WCF 文件,但是当移动到 https 时,我无法访问 WCF 服务。错误详情如下:

An unknown error occurred. Please contact your system Administrator for more information.

An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.

  at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
  at FileSearch.SearchServices.GetTypeofFileDetailedCompletedEventArgs.get_Result()
  at FileSearch.Home.<SearchButton_Click>b__0(Object s, GetTypeofFileDetailedCompletedEventArgs ea)
  at FileSearch.SearchServices.SearchServiceClient.OnGetTypeofFileDetailedCompleted(Object state)

我看到过关于这个问题的不同帖子,但没有任何东西可以为我指明正确的方向。

以下是有关我的 web.config 文件的详细信息,该文件用于托管 silverlight 应用程序以及 WCF 服务的 Web 应用程序。

<services>
  <service name="FileSearch.Web.Services.SearchService">
    <endpoint address="" binding="customBinding" bindingConfiguration="FileSearch.Web.Services.SearchService.customBinding0" contract="FileSearch.Web.Services.SearchService" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

这里是 servicerefernce.clientconfig 文件:

<configuration>
    <system.serviceModel>
        <bindings>
            <customBinding>
                <binding name="CustomBinding_SearchService">
                    <binaryMessageEncoding />
                    <httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="../Services/SearchService.svc"
                binding="customBinding" bindingConfiguration="CustomBinding_SearchService"
                contract="SearchServices.SearchService" name="CustomBinding_SearchService" />
        </client>
    </system.serviceModel>
</configuration>

更新:

我收到了仅在 https 模式下运行服务的答案。我想在 http 和 https 模式下运行服务。

对此有什么想法吗?

【问题讨论】:

  • 您可以发布您尝试在服务中调用的操作的代码吗?听起来那个操作有异常。
  • 但它在 http 上运行良好。问题在于https
  • 您在绑定的配置文件中没有任何安全设置 - 这可能是问题的一部分?

标签: asp.net wcf silverlight-4.0 ssl https


【解决方案1】:

为了支持 Https 方案,您需要将传输更改为 &lt;httpsTransport&gt;. 我看到您正在使用 &lt;httpTransport&gt;.

【讨论】:

  • 我试过这个,但没有用。我用binding=wsHttpBinding 尝试了Vinay 的方法,它有效,但它只适用于https 模式。我希望它在 http 和 https 模式下运行...
【解决方案2】:

指定两个端点,一个带有安全传输,一个没有。

【讨论】:

  • 没错。有效。此外,我必须更新导致 clientconfig 文件中的两个端点和两个绑定的服务引用,然后根据 System.Windows.Browser.HtmlPage.Document.DocumentUri.Scheme.StartsWith("https") 的名称动态访问绑定。这个)
【解决方案3】:

尝试添加

<security mode="Transport" />

在您的服务配置文件中。 this 应该嵌套在绑定节点内。

查看this 文章中的安全模式配置部分。

【讨论】:

  • 您的意思是在此添加&lt;security authenticationMode="UserNameOverTransport"&gt;&lt;/security&gt; 吗?因为在安全性下没有直接的mode 属性...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-12-01
  • 2014-12-20
  • 1970-01-01
  • 1970-01-01
  • 2010-11-04
  • 1970-01-01
  • 2012-04-30
相关资源
最近更新 更多