I wrote a very simple web service, which you can see below:
SERVER:
<?php
ini_set('error_reporting', E_STRICT);
require_once("nuSOAP/lib/nusoap.php");
$namespace = "http://localhost/webservice/index.php";
$server = new soap_server();
$server->soap_defencoding = 'utf-8';
$server->decode_utf8 = false;
$server->configureWSDL("HelloExample");
$server->wsdl->schemaTargetNamespace = $namespace;
$server->register(
'HelloWorld',
array('name'=>'xsd:string'),
array('return'=>'xsd:string'),
$namespace,
false,
'rpc',
'encoded',
'Simple Hello World Method');
$POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : '';
$server->service($POST_DATA);
exit();
?>
CUSTOMER:
<!doctype html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8"/>
</head>
<body>
<?php
require_once("nuSOAP/lib/nusoap.php");
$client = new nusoap_client('http://localhost/webservice/index.php?wsdl');
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = true;
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
die();
}
$parameters = array('name' => "محمد");
$result = $client->call('HelloWorld', $parameters);
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
die();
}
else
{
echo $result;
}
?>
</body>
</html>
this should return Hello محمد But is this return Hello ????
is a unicode problem?
any help to fix this would be appreciated
source
share