使用wsdl文件: 生成wsdl <?php require('person.class.php'); // 引入生成wsdl的类文件 require('SoapDiscovery.class.php'); $wsdl = new SoapDiscovery('person','person'); //第一个类名,第二个随意 $wsdl->getWSDL(); ?> person.class.php <?php class person{ public $b = 10; public function name(){ return '阿三'; } public function add($a,$b){ return $a.$b; } } ?> Clint.php <?php $soap = new SoapClient('http://localhost/test/web_service/person.wsdl'); // 引入wsdl文件 echo $soap->name(); echo $soap->add(10); //结果 阿三1010 ?> Service.php <?php include ('person.class.php'); $soap = new SoapServer('http://localhost/test/web_service/person.wsdl'); $soap->setClass('person'); $soap->handle(); ?>