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

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

WBOY
WBOYOriginal
2016-06-07 11:37:081693browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn