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

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

WBOY
WBOYOriginal
2016-06-07 11:37:081657Durchsuche

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn