wcf +响应消息的内容类型text / html与绑定的内容类型不匹配(application / soap + xml; charset = utf-8)

时间:2017-02-23 13:17:22

标签: c# wcf utf-8 binding character-encoding

我面临以下错误 " 响应消息的内容类型text / html与绑定的内容类型(application / soap + xml; charset = utf-8)不匹配。 如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前514个字节是" 。下面是我的绑定和配置文件

let lastmonthstart = startofmonth(now(), -1);
let lastmonthend = endofmonth(lastmonthstart);
availabilityResults
| where timestamp between(lastmonthstart .. lastmonthend)
| summarize failurecount=countif(success == 0), successcount=countif(success == 1) by name, bin(timestamp, 5m)
| project failure = iff(failurecount > 0 and successcount == 0, 1, 0), name, bin(timestamp, 5m)
| summarize totalFailures = sum(failure), totalTests = count(failure) by name
| project ["Name"] = name, ["SLA"] = todouble(totalTests - totalFailures) / todouble(totalTests) * 100
| order by ["SLA"]

什么问题不确定我面对的是什么......

1 个答案:

答案 0 :(得分:4)

大部分时间意味着您的主机返回错误页面(因为内容类型为text/html,如上所述)而不是您的服务返回application/soap+xml中的响应。

您应该检查服务的网址(http(s)://localhost{:port}/{subSite}/(WCF URL).svc)是否可以成功激活您的服务。如果您的服务可以被激活,那么您应该尝试的下一件事是通过以下方式在客户端和服务端启用wcf跟踪:

  • 右键单击您的web.config / app.config并单击Edit WCF Configuration
  • Diagnostics部分下,启用Log Auto FlushMessageLoggingTracing,当然也可以指定主机标识有权写入的路径。
  • 执行该服务调用后检查跟踪文件。然后你应该看到主机返回的html并找出真正的问题。
相关问题