2011-07-09 84 views
0

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

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) 

我已经看到了关于这个问题不同的岗位,但没有指向我在一个正确的方向。

下面是关于承载Silverlight应用程序以及WCF服务的Web应用程序的web.config文件的详细信息。

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

UPDATE:

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

有关于此的任何想法?

+0

您可以发布您尝试在服务中调用的操作的代码吗?这听起来像是该操作中有一个例外。 – Tim

+0

但它在'http'上正常工作。问题出在'https' –

+0

你的配置文件中没有任何安全设置 - 这可能是问题的一部分? – Tim

回答

2

指定的两个端点一个有安全运输和一个没有它。

+0

这是正确的。有效。此外,我不得不更新服务引用,导致clientconfig文件中有两个端点和两个绑定,然后根据'System.Windows.Browser.HtmlPage.Document.DocumentUri.Scheme.SttmlWith的名称动态访问绑定。 (“https”)'做了这一切......(对于任何后来查看此内容的人) –

1

尝试添加

<security mode="Transport" /> 

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

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

+0

你的意思是为此添加''?因为在安全性方面没有简单的'mode'属性... –

0

为了支持https配置,你需要改变运输<httpsTransport>.我看你使用<httpTransport>.

+0

我试过了,但没有奏效。我尝试了'bind = wsHttpBinding'的Vinay方法,它工作正常,但它只适用于https模式。我希望它运行http和https模式... –