2011-08-01 58 views
0

我在IIS 7上部署了一個WCF服務。 從瀏覽器瀏覽服務表明它運行良好。 從Silverlight應用程序連接到服務產生以下錯誤:使用Silverlight連接到部署在IIS上的WCF

The HTML document does not contain Web service discovery information. Metadata contains a reference that cannot be resolved: 'http://localhost:81/SdkService.svc'. Content Type application/soap+xml; charset=utf-8 was not supported by service http://localhost:81/SdkService.svc . The client and service bindings may be mismatched. The remote server returned an error: (415) Cannot process the message because the content type 'application/soap+xml; charset=utf-8' was not the expected type 'text/xml; charset=utf-8'.. If the service is defined in the current solution, try building the solution and adding the service reference again.

服務項目符合.NET 4.0和該服務的應用程序池也.NET 4.0

Silverlight客戶端是還與.NET 4.0

編譯這裏的服務的web.config:

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 

    <system.web> 
    <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
     <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </assemblies> 
    </compilation> 
    </system.web> 
    <system.serviceModel> 
    <diagnostics> 
     <messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" /> 
    </diagnostics> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
      <dataContractSerializer maxItemsInObjectGraph="6553600"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    </system.webServer> 

</configuration> 
enter code here 

回答

1

的Silverlight只支持basicHttpBinding的。我相信WCF默認是wsHttpBinding,所以你可能需要改變它,然後更新你的服務引用。