我尝试使用wcf调用php webservice。我搜索了一些公共PHP服务,看看是否可以复制我收到的错误,并创建了两个不同的单元测试来演示。
测试失败时,我得到以下错误:
system.serviceModel.protocolException:响应消息的内容类型text/xml;charset=iso-8859-1与绑定的内容类型(text/xml;charset=utf-8)不匹配。如果使用自定义编码器,请确保正确实现了isContentTypeSupported方法。响应的前601个字节是:'
以下是单元测试:
[TestMethod]
public void WCF_Call_To_SiteInspect() {
//This service doesn't work. It gets the same communication error as our own servers
var soapClien = new SiteInspect.SiteInspectPortClient();
var response = soapClien.doSiteInspect("Any", "Any", "www.google.com");
Assert.IsTrue(response.serverTime.Length > 0);
}
[TestMethod]
public void WCF_Call_To_FinnService() {
//This service works.... in looking at the wsdl it appears that it references a separate wsdl file. Is this the reason?
var soapClient = new NuSoapFinnService.finnwordsPortTypeClient();
var finnLyric = soapClient.getRandomNeilFinnLyric("text");
Assert.IsTrue(finnLyric.Length > 0);
}
底部的测试用例(Finn服务)通过了以下URL:
http://www.nickhodge.com/nhodge/finnwords/finnwords.wsdl
给定以下URL,第一个测试用例失败:
http://www.flash-db.com/services/ws/siteInspect.wsdl
我在WSDL中看到的唯一区别是Finn服务引用了一个无关文件。xmlns:tns=“http://www.nickhodge.com/nhodge/finnwords/finnwords.wsdl.此bug是否与WCF一起使用,而WCF需要特定格式的WSDL?