Reputation: 18327
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.

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);
$result_1
properly$result_2
(It always returns BLANK)Please suggest me what should i do with it?
Upvotes: 5
Views: 19971
Reputation: 63
The question is very old but there is a solution:
$result_2 = html_entity_decode($client->GetText_withSpecialCharacter(), ENT_QUOTES | ENT_XML1);
But 
does not seem to be a valid UTF-8 character. 0xE
is Shift Out character.
Upvotes: 0
Reputation: 1
Maybe you can try this :
$myString = $client->GetText_withSpecialCharacter();
$result_2 = urldecode($myString);
if ($myString != urlencode($result_2)) {
$result_2 = mb_convert_encoding($myString, "UTF-8", mb_detect_encoding($myString,"auto",true));
}
Upvotes: 0
Reputation: 5239
try
$result_1 = urldecode($client->GetText());
$result_2 = urldecode($client->GetText_withSpecialCharacter());
Upvotes: 0
Reputation: 95101
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'));
Upvotes: 1