問題描述
我在讓 PHP 與 SoapServer + UTF-8 配合使用時遇到問題.任何時候任何人發送帶有非英語字符(即有趣的引號、重音字符等)的 Soap 請求時,SoapServer 都會拋出一個異常,說錯誤的請求".我試過用 utf8_decode 解碼請求,甚至 HTML 特殊字符對文本進行編碼.沒有什么對我有用.
I'm having problems getting PHP to play nicely with SoapServer + UTF-8. Anytime anyone sends a Soap Request with non english characters (i.e. funny quotes, accented characters, etc) the SoapServer throws an exception saying "Bad Request." I've tried decoding the request with utf8_decode and even HTML Special Characters encoded the text. Nothing is working for me.
我正在尋找正確方向的點,因為我現在迷路了.
I'm looking for a point in the right direction because I'm lost at the moment.
推薦答案
確保 SoapServer 和 SoapClient 使用 UTF- 初始化8 編碼:
make sure both SoapServer and SoapClient are initialized with UTF-8 encoding:
$client = new SoapClient("some.wsdl", array('encoding'=>'UTF-8'));
$server = new SoapServer("some.wsdl", array('encoding'=>'UTF-8'));
使用有趣的引號、重音字符等"處理請求的 XML.驗證?
does the XML of the requests with the "funny quotes, accented characters, etc." validate?
這篇關于克服 PHP、SoapServer、UTF-8 和非英文字符的編碼問題?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!