使用Silverlight连接到IIS上的已部署WCF

时间:2011-08-01 08:00:57

标签: silverlight wcf iis

我在IIS 7上部署了WCF服务。 从浏览器浏览服务表明它运行正常。 从Silverlight应用程序连接到服务会产生以下错误:

  

HTML文档不包含Web服务发现信息。   元数据包含无法解析的引用:'http:// localhost:81 / SdkService.svc'。   内容类型application / soap + xml;服务http://localhost:81/SdkService.svc不支持charset = utf-8。客户端和服务绑定可能不匹配。   远程服务器返回错误:(415)无法处理消息,因为内容类型为'application / soap + xml; charset = utf-8'不是预期的类型'text / xml;字符集= UTF-8' ..   如果在当前解决方案中定义了服务,请尝试构建解决方案并再次添加服务引用。

服务项目符合.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 个答案:

答案 0 :(得分:1)

Silverlight仅支持basicHttpBinding。我相信WCF默认为wsHttpBinding,因此您可能需要更改此设置,然后更新服务引用。