我想调用一个使用WCF的PHP web服务。我搜索了一些公共PHP服务,看看我是否可以复制我收到的错误,并创建了2个不同的单元测试来演示。从WCF调用时,NuSoap是否必须以某种方式进行配置?
失败的测试我得到以下错误: 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);
}
测试用例上底面(芬兰服务)传递通过以下URL:http://www.nickhodge.com/nhodge/finnwords/finnwords.wsdl
的第一个测试案例失败给出以下URL:http://www.flash-db.com/services/ws/siteInspect.wsdl
我可以看到在wsdl唯一的区别是芬兰服务引用一个无关的文件。的xmlns:TNS =“http://www.nickhodge.com/nhodge/finnwords/finnwords.wsdl是与WCF是需要一个特定格式的WSDL
正常工作就addedd行:。$服务器 - > soap_defencoding = 'UTF-8'; – Mario 2011-04-26 21:49:19