<?php
header("Content-Type: text/html;charset=utf-8");
require_once('lib/nusoap.php');
$client = new soapclient('http://www.xxx.com/webServiceData.asmx?WSDL', true);
$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$page=5;
$pageSize=50;
$param = array('page'=>$page,'pagesize'=>$pageSize,"","");
$result = $client->call('GetUserDataSetByPage', array('parameters' => $param));
print_r($param);
// Check for a fault
if ($client->fault) {
echo '<h2>Fault</h2><pre>';
print_r($result);
echo '</pre>';
}
else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<h2>Error</h2><pre>' . $err . '</pre>';
}
else {
// Display the result
echo '<h2>Result</h2><pre>';
print_r($result);
echo '</pre>';
}
}
?>
PS:如果加上了
$client->soap_defencoding = 'utf-8';
$client->decode_utf8 = false;
这两句返回的仍然是乱码,别忘记页面顶部加上:
header("Content-Type: text/html;charset=utf-8");