Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP SOAP Client with Special Characters (Encoding)?

I'm trying a SOAP Client with PHP. It is ok as i simply know it. But there is a problem when the Data contains Special Character inside.

  • Special Character like ♫ inside. (It comes as Hex-code  in the data.)

Following is the sample:

header('Content-Type: text/plain; charset=UTF-8');
$client = new SoapClient('http://www.example.com/webservice.asmx?WSDL', array('trace' => 1, 'encoding'=>'UTF-8'));

$result_1 = $client->GetText();
$result_2 = $client->GetText_withSpecialCharacter(); //Data contains `` hex-code (♫ Special Character)

var_dump($result_1);
var_dump($result_2);
  • I always got $result_1 properly
  • But, NEVER got $result_2 (It always returns BLANK)

Please suggest me what should i do with it?

like image 737
夏期劇場 Avatar asked Nov 13 '22 21:11

夏期劇場


1 Answers

You can try setting the encoding to UTF-8

Example

$client = new SoapClient('http://www.example.com/webservice.asmx?WSDL', array('trace' => 1, 'encoding'=>' UTF-8'));
like image 112
Baba Avatar answered Nov 15 '22 10:11

Baba