1. 程式人生 > >php實現soap簡單示例程式碼

php實現soap簡單示例程式碼

1、server.php
function getName() {
    return 'test';
}
$soapServer = new SoapServer(null, array(
    'uri' => 'http://demo1/soap')
);
$soapServer->addFunction('getName');
$soapServer->handle();

2、client.php
$soapClient = new SoapClient(null, array(
    'location' => 'http://demo1/soap/server.php',
    'uri' => 'http://demo1/soap'
));
$result = $soapClient->getName();
echo $result;