您的位置:首页 > 编程语言 > PHP开发

//serverSoap_class.php

2016-04-15 08:54 661 查看
<?php

//serverSoap_class.php

$classExample = array();

 $soap = new SoapServer(null,array('uri'=>"http://127.0.0.1/",'classExample'=>$classExample));

 $soap->setClass('chesterClass');

 $soap->handle();

 class chesterClass {

     public $name = 'Chester';

     function getName() {

         return $this->name;

     }

 }

<?php

 //client端 clientSoap_class.php

 try {

     $client = new SoapClient(null,

         array('location' =>"http://127.0.0.1/myphp/serverSoap_class.php",'uri' => "http://127.0.0.1/")

     );

     echo $client->getName();

 } catch (SoapFault $fault){

     echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: