Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
999 views
in Technique[技术] by (71.8m points)

xml - Overcome Encoding Problems with PHP, SoapServer, UTF-8, and non English Characters?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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'));

does the XML of the requests with the "funny quotes, accented characters, etc." validate?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...