Home >Backend Development >PHP Problem >What should I do if php calls webservice and the code is garbled?

What should I do if php calls webservice and the code is garbled?

藏色散人
藏色散人Original
2020-09-11 09:34:271698browse

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.

What should I do if php calls webservice and the code is garbled?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn