From: Augusto Flavio on
Hi guys,


I created a simple wsdl web service. Everything works fine, but when I
fill the fields with accents and send the soap request, the PHP
returns me an error:


Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR:
Encoding: string 'ol\xe1...' is not a valid utf-8 string in
PATH\cilent.php 16 Stack trace: #0 [internal function]:
SoapClient->__call('Send', Array) #1 PATH\cilent.php(16):
SoapClient->Send(Array) #2 {main} thrown in PATH\cilent.php on line 16


I tested this same request using the eclipse web service explorer(It's
a java client web service inside the eclipse IDE) and the response was
ok.


I found few topics about this issue on the google. One related
solution to this problem is use the utf8_encode() function. I tried
add this function before to send the soap request but didnt worked.


I think that this problem is in the PHP soap client because using the
eclipse web service explorer it works fine.


Here is my php soap client:


$client = new SoapClient('http://app/webservice.wsdl');
$return = $client->Send(array('token' => '123123', 'message' => array(
'text' => 'This is a string with special characters á é í ó ú', 'dest'
=> 'John', 'sender' => 'Augusto')));

As I said I tried to use the utf8_encode() here:

$return = $client->Send(array('token' => '123123', 'message' => array(
'text' => utf8_encode('This is a string with special characters á é í
ó ú'), 'dest' => 'John', 'sender' => 'Augusto')));

But the problem still.

I tried also add the propertie defencoding in the soap server:

$server->soap_defencoding = 'UTF-8';

But still not working.


What I'm missing?



Thanks



Augusto Morais
From: Richard Quadling on
On 22 July 2010 21:59, Augusto Flavio <aflavio(a)gmail.com> wrote:
> Hi guys,
>
>
> I created a simple wsdl web service. Everything works fine, but when I fill
> the fields with accents and send the soap request, the PHP returns me an
> error:
>
>
> *Fatal error*: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding:
> string 'ol\xe1...' is not a valid utf-8 string in PATH\cilent.php 16 Stack
> trace: #0 [internal function]: SoapClient->__call('Send', Array) #1
> PATH\cilent.php(16): SoapClient->Send(Array) #2 {main} thrown in *
> PATH\cilent.php* on line *16*
>
>
> I tested this same request using the eclipse web service explorer(It's a
> java client web service inside the eclipse IDE) and the response was ok.
>
>
> I found few topics about this issue on the google. One related solution to
> this problem is use the utf8_encode() function. I tried add this function
> before to send the soap request but didnt worked.
>
>
> I think that this problem is in the PHP soap client because using the
> eclipse web service explorer it works fine.
>
>
> Here is my php soap client:
>
>
> $client = new SoapClient('http://app/webservice.wsdl');
> $return = $client->Send(array('token' => '123123', 'message' => array(
> 'text' => 'This is a string with special characters á é í ó ú', 'dest' =>
> 'John', 'sender' => 'Augusto')));
>
> As I said I tried to use the utf8_encode() here:
>
> $return = $client->Send(array('token' => '123123', 'message' => array(
> 'text' => utf8_encode('This is a string with special characters á é í ó ú'),
> 'dest' => 'John', 'sender' => 'Augusto')));
>
> But the problem still.
>
> I tried also add the propertie defencoding in the soap server:
>
> $server->soap_defencoding = 'UTF-8';
>
> But still not working.
>
>
> What I'm missing?
>
>
>
> Thanks
>
>
>
> Augusto Morais
>

Not 100% sure on this, but, are you saving the source code in UTF-8 format?

If not, then the error is quite correct.

Also, utf8_encode() only deals with converting ISO-8859-1 to UTF-8,
so, again, if the source code is NOT in ISO-8859-1 then you are not
going to get the conversion.