简体   繁体   English

PHP Zend SOAP中的UTF8错误

[英]UTF8 Errors in PHP Zend SOAP

I am programming a "SOAP Proxy" that connects to a SOAP Server (Main Server) and is a SOAP Server itself. 我正在编程连接到SOAP服务器(主服务器)的“ SOAP代理”,它本身就是SOAP服务器。 I am programing one Client too that will contact with this SOAP Proxy. 我也在编程一个将与此SOAP代理联系的客户端。

When the SOAP Client call a specific metodh from the SOAP Proxy I receive this error: 当SOAP客户端从SOAP代理调用特定方法时,我收到此错误:

SOAP-ERROR: Encoding: string 'Pir\xe4...' is not a valid utf-8 string 

I do not know in what language the Main Server is implemented. 我不知道主服务器使用哪种语言。 I am working with PHP in the Proxy Server and in the Client. 我正在代理服务器和客户端中使用PHP。 The information comes from the Main Server and is a complex object. 该信息来自主服务器,是一个复杂的对象。

I found a workaround to the problem. 我找到了解决该问题的方法。 Adding this line before return the content in the Proxy Server eveithyng is ok: 在返回代理服务器eveithyng中的内容之前添加此行是可以的:

$result = json_decode(utf8_encode(json_encode($result)));

But, i think this is quinte ninja function to do. 但是,我认为这是经典的忍者功能。 There are a better way? 有更好的办法吗? Anyone found this kind of problem in the past? 过去有人发现这种问题吗? Or is something missing in my ideia? 还是我的思想缺失?

I would say, it is ok to encode the return ? 我会说,可以编码返回值吗? But more sexy is it to use the Zend Framework methods to encode it: 但是,使用Zend Framework方法对其进行编码更为性感:

// could be set in bootstrap
Zend_Json::$useBuiltinEncoderDecoder = true;

// should be correct utf8
$result = Zend_Json::encode($result);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM