首頁 >php教程 >php手册 >好多人问thinkphp3.2中如何调用soap,其实很简单

好多人问thinkphp3.2中如何调用soap,其实很简单

WBOY
WBOY原創
2016-06-07 11:37:081704瀏覽

自己写的欢迎指正,soap如何调用thinkphp3.2
namespace Home\Controller;<br> use Think\Controller;<br> class IndexController extends Controller {<br>     public function index(){        <br>         $host = $_SERVER['HTTP_HOST']; <br>         $module = MODULE_NAME; <br>         $action = ACTION_NAME;<br>         $server="";<br>         $wsdl="";      <br>         $soaparray=array("location"=>"http://".$host."/".$module."/".$action,"uri"=>$action.".html");<br>         $server= new \SoapServer(null,$soaparray); <br>         $server->setClass(get_class($this)); <br>         $server->handle();        <br> <br>     }  <br>     public  function Add($a,$b)<br>    {<br>       return $a+$b;<br>    }<br>    public function testsoap(){<br>         $soap = new \SoapClient(null,array( "location" => "http://yourhost/index/index","uri"=> "index.html", "style"    => SOAP_RPC, "use" => SOAP_ENCODED));<br>         echo $soap->Add(1,2);<br>     unset($soap); <br>     }<br> }

AD:真正免费,域名+虚机+企业邮箱=0元

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn