这是我的 nusoap 服务器 php 代码:
<?PHP
function Test( $name = '' )
{
if( empty( $name ) )
{
throw new SoapFault( '-1' , 'Error !' );
}
return $name;
}
$WS = new nusoap_server;
$WS->configureWSDL('WebService', 'urn:WebService');
$WS->wsdl->schemaTargetNamespace = 'urn:WebService';
$WS->soap_defencoding = 'UTF-8';
$WS->decode_utf8 = false;
$WS->register(
'Test',
array( 'name' => 'xsd:string' ),
array(
'return' => 'xsd:string'
),
'urn:WebService',
'urn:WebService#Test',
'rpc',
'encoded',
'Test Function'
);
$HTTP_RAW_POST_DATA = isset( $HTTP_RAW_POST_DATA ) ? $HTTP_RAW_POST_DATA : '';
$WS->service( $HTTP_RAW_POST_DATA );
?>
这是我的客户端 php 代码:
<?PHP
$S = new SoapClient( 'http://localhost/server.php' );
try {
echo $S->Test( '' );
} catch( SoapFault $s )
{
echo '<pre dir="ltr">';
print_r( $s->getMessage() );
echo '</pre>';
}
?>
为什么我的客户的输出是:looks like we got no XML document
?
我想抛出异常看看Error !
我的问题在哪里?