2008-10-09 36 views
0

我想調用一個使用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

回答

1

確保設置UTF-8編碼這個bug?使用soap_defencoding在PHP代碼

如果你想要更多的相關信息,請參閱this blog post.

+0

正常工作就addedd行:。$服務器 - > soap_defencoding = 'UTF-8'; – Mario 2011-04-26 21:49:19

相關問題