微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

.net – Silverlight WCF异常:期望应用程序/ soap xml,接收文本/ xml

我有一个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>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐