Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAP-ERROR: Encoding: string ... is not a valid utf-8 string

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


Followup: Problem was due to a truncated string by the database. The field was set to VARCHAR(50) and it truncated exactly in the middle of the encoded value.

like image 479
Gabriel Spiteri Avatar asked Nov 04 '11 07:11

Gabriel Spiteri


1 Answers

What about change the encoding settings:

SERVER:

$server = new SoapServer("some.wsdl", array('encoding'=>'ISO-8859-1')); // for 'windows-1252' too

CLIENT:

$server = new SoapClient("some.wsdl", array('encoding'=>'ISO-8859-1')); // for 'windows-1252' too

... then the conversion is done automatically to UTF-8, I had the similiar problem, so this helped me, so it is tested

like image 140
Vaclav Svara Avatar answered Sep 25 '22 02:09

Vaclav Svara