SOAP-ERROR:编码:string ...不是一个有效的utf-8字符串 [英] SOAP-ERROR: Encoding: string ... is not a valid utf-8 string

查看:452
本文介绍了SOAP-ERROR:编码:string ...不是一个有效的utf-8字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Zend Framework构建的Web服务。其中一种方法是发送有关订单的详细信息。我遇到了一些编码问题。返回的值之一包含以下内容:



Jaime Torres Bodet#322-A Loma de SantaMaría上校



webservice返回以下错误:

 < SOAP-ENV:Envelope xmlns :SOAP-ENV = http://schemas.xmlsoap.org/soap/envelope/ > 
< SOAP-ENV:Body>
< SOAP-ENV:Fault>
< faultcode> SOAP-ENV:服务器< / faultcode>
< faultstring> SOAP-ERROR:Encoding:string'Jaime Torres Bodet#322-A Colon Lomas de Santa Mar \xc3 ...'不是有效的utf-8字符串< / faultstring>
< / SOAP-ENV:Fault>
< / SOAP-ENV:Body>
< / SOAP-ENV:Envelope>

我该怎么解决这个问题?



谢谢

解决方案

今天遇到同样的问题 - 导致该问题的代码是:

  $ request-> Text = substr($ text,0,40); 

将substr更改为mb_substr似乎可以解决问题:



$ pre> $ request-> Test = mb_substr($ text,0,40,'utf8');


Hi I have a web service built using the Zend Framework. One of the methods is intended to send details about an order. I ran into some encoding issue. One of the values being returned contains the following:

Jaime Torres Bodet #322-A Col. Lomas de Santa María

The webservice is returning the following fault:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring>SOAP-ERROR: Encoding: string 'Jaime Torres Bodet #322-A Col. Lomas de Santa Mar\xc3...' is not a valid utf-8 string</faultstring>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

How should I go about this problem?

Thanks

解决方案

Today I run into same problem - the code which caused that problem was:

$request->Text = substr($text, 0, 40);

changing substr to mb_substr seems to solve the issue:

$request->Test = mb_substr($text, 0, 40, 'utf8');

这篇关于SOAP-ERROR:编码:string ...不是一个有效的utf-8字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆