2014-01-15 90 views
1

我在php中使用本地soap服務器類創建了一個soap服務器。我需要的編碼是ISO-8859-1。 我試圖做到這一點,同時創造這樣的SOAP服務器:php設置soap服務器響應的編碼類型

$server = new SoapServer('./AdviseAndPay.wsdl',array('encoding'=>'ISO-8859-1'));

然而,對於HTTP頭中的編碼和SOAP響應仍是UTF-8。

我正在返回肥皂響應的本機php SoapVar對象。我已經嘗試了頭內容類型與此代碼設置爲ISO-8859-1

header('Content-Type: text/xml;charset=iso-8859-1') 剛剛返回SoapVar之前。 但是我仍然在http頭文件和soap響應中得到utf-8的編碼。

我已經嘗試了在stackoverflow中的答案,並在定義肥皂服務器時設置了encdoding類型的答案,但這並沒有爲我工作。

你能幫我嗎。 在此先感謝。

Edit: 這是肥皂服務器響應的原始http響應。

HTTP/1.1 200 OK 
Date: Wed, 15 Jan 2014 04:47:16 GMT 
Server: Apache/2.2.22 (Ubuntu) 
X-Powered-By: PHP/5.4.9-4ubuntu2.4 
Cache-Control: no-store, no-cache, must-revalidate, private, max-age=0 
Pragma: no-cache 
Expires: Wed, 11 Jan 1984 05:00:00 GMT 
Vary: Accept-Encoding 
Content-Encoding: gzip 
Content-Length: 225 
Keep-Alive: timeout=5, max=100 
Connection: Keep-Alive 
Content-Type: text/xml; charset=utf-8 

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> 
<SOAP-ENV:Body><ns2:responseType xmlns:ns2="http://tempuri.org/response"> 
<code>00</code> 
<message>incorrect username/password</message> 
<responseBody> 
<responseStr>5</responseStr> 
</responseBody> 
</ns2:responseType> 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

Edit

我發現有關於編碼類型SOAP服務器響應的PHP錯誤報告。最新評論說,有一個錯誤是在2008年。 這裏是鏈接:php bug

任何人都可以驗證他們是否有類似的問題,肥皂服務器編碼?

+0

如果任何人有任何經驗,請幫忙 –

回答

0

確保您不要在開發時緩存那些必需的WSDL文件。

ini_set('soap.wsdl_cache_enabled', '0'); 

以下配置適用於我。

// Run SOAP Server 
ini_set('soap.wsdl_cache_enabled', '0'); 
$soap_config = array('encoding' => 'ISO-8859-1'); 
$soapserver = new SoapServer('soap.wsdl', $soap_config); 
... 

// Create SOAP client 
$soap_client = new SoapClient('soap.wsdl', array('encoding' => 'ISO-8859-1', 'cache_wsdl' => WSDL_CACHE_NONE)); 
+0

有一個死在我的肥皂服務器的末尾可以有任何區別。沒有'die'命令,肥皂服務器似乎不工作 –

+0

我把'ini_set',但仍然是相同的結果。 –

+0

這不是一個正常的行爲。不幸的是,如果你不提供更多的細節,包括你的源代碼,我不能幫你。否則會導致錯誤的故障排除。 –