Home >Backend Development >PHP Problem >What should I do if php calls webservice and the code is garbled?
The solution to the garbled code when calling webservice in php: first open the "nusoap.php" file; then modify the content to "var $soap_defencoding = 'UTF-8';"; finally, specify the encoding when calling.
Recommended: "PHP Video Tutorial"
If there is Chinese in the webservice, the returned value will become Garbled code. I checked the response result and it is correct. There should be a problem when using nusoap to process it.
Changed two places in nusoap.php and it was OK.
Changed Place:
86行的:var $soap_defencoding = 'UTF-8'; 4998行的:var $decode_utf8 = false;
You can leave it unchanged, but you must specify the encoding when calling.
1. Server-side interface
$server=new soap_server(); //生成对象 $server->soap_defencoding = 'utf-8'; $server->decode_utf8 = false;
2. Calling interface
$client = new soapclient('http://localhost/TestService/Service1.asmx?WSDL', true); $client->soap_defencoding = 'UTF-8'; $client->decode_utf8 = false;
The above is the detailed content of What should I do if php calls webservice and the code is garbled?. For more information, please follow other related articles on the PHP Chinese website!