Pablo
Pablo

Reputation: 1

special character in php soap request wrongly displayed in xml out package

I'm using a webservice that in my request includes a ¥ symbol (chr 0165). I have set the encoding on my soap client to:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

But when I look at my outgoing soap package the "¥" is changed to "Â¥"

I'm not good at encoding but I've tried a number of different combinations, using UTF8-ENCODE etc, to no avail....I just want my outbound soap package to show "¥" for every "¥" in my string variable.

Update:

I must still be doing something wrong...when I add the utf8_decode("my string with ¥"), and I leave the encoding as stated:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

I still get the "my string with ¥" as parameter in my outbound soap packet.

if i leave out the encoding part in:

$soap = new MySoapClient('address.wsdl', array('trace' => 1, 'encoding'=>'ISO-8859-1'));

combined with the utf8_decode("my string with ¥") I get the following soap error:

SOAP-ERROR: Encoding: string "my string with ¥" is not a valid utf-8 string.....

Any suggestions?

Upvotes: 0

Views: 2137

Answers (1)

Peter Bailey
Peter Bailey

Reputation: 105868

You are feeding a UTF-8 encoded YEN SIGN but telling the service that its encoded as ISO-8859-1.

In UTF-8, that character is encoded into two bytes: 0xC2 and 0xA5.

In ISO-8859-1, those two bytes are decoded into two separate characters, LATIN CAPITAL LETTER A WITH CIRCUMFLEX and YEN SIGN respectively.

To fix this, try applying utf8_decode to the value before using it in the SOAP call.

Upvotes: 1

Related Questions