Home> php教程> php手册> body text

NuSOAP 调用 Web Service 出现乱码的解决方法:

WBOY
Release: 2016-06-13 11:26:08
Original
1419 people have browsed it

实际上,开启了调试功能的朋友,相信会发现 $client->response 返回的是正确的结果,为什么 $result = $client->call($action, array(‘parameters’ => $param)); 却是乱码呢?

研究过 NuSOAP 代码后我们会发现,当 xml_encoding 设置为 UTF-8 时,NuSOAP 会检测 decode_utf8 的设置,如果为 true ,会执行 PHP 里面的 utf8_decode 函数,而 NuSOAP 默认为 true,因此,我们需要设置:

代码如下 复制代码

$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'utf-8';


source:php.cn
Statement of this Website
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
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!