.net - Silverlight+WCF 异常 : Expecting application/soap+xml, 收到文本/xml

标签 .net wcf silverlight exception-handling wcf-configuration

我有一个 Silverlight 应用程序,我想在其中调用 WCF 服务。调用服务时,我从服务器收到以下响应:

415 Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8



有没有人遇到过这个问题?有谁知道我需要调整哪些配置设置?任何有关如何解决此问题的信息将不胜感激。

最佳答案

那么,您可以尝试使用VS2008中的“启用Silverlight的WCF服务”模板,并比较差异?我希望您需要使用 basicHttpBinding 并且正在使用更奇特的东西。

有关信息,这里是默认 Silverlight/WCF 服务的 web.config 部分:

 <system.serviceModel>
  <behaviors>
   <serviceBehaviors>
    <behavior name="MySite.Service1Behavior">
     <serviceMetadata httpGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
   </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <services>
   <service behaviorConfiguration="MySite.Service1Behavior"
       name="MySite.Service1">
    <endpoint address="" binding="basicHttpBinding"
       contract="MySite.Service1" />
    <endpoint address="mex" binding="mexHttpBinding"
       contract="IMetadataExchange" />
   </service>
  </services>
 </system.serviceModel>

关于.net - Silverlight+WCF 异常 : Expecting application/soap+xml, 收到文本/xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/493883/

相关文章:

c# - Html Agility Pack可以用来解析HTML片段吗?

c++ - 类 WCF 的 native C++ 库

.net - 在 IIS Express 中托管 WCF 服务时出现问题

c# - 在Silverlight中显示播放媒体文件的波形?

c# - 限制对特定程序集的访问

c# - SharpSSH 的 Scp 对象无法复制大于 2GB 的文件

.net - WF4 : Validate that all exit statuses of activity has transitions to other activities

c# - WCF:客户端发送值但服务器收到空字符串

silverlight - 将代码保留在 XAML 代码之外的真正优势是什么?

silverlight - VertexBuffer.GetData() 和 Silverlight 5