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

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

WBOY
WBOY原创
2016-06-07 11:37:081693浏览

自己写的欢迎指正,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