欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

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

程序员文章站 2022-06-12 17:38:13
...
自己写的欢迎指正,soap如何调用thinkphp3.2
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$host = $_SERVER['HTTP_HOST'];
$module = MODULE_NAME;
$action = ACTION_NAME;
$server="";
$wsdl="";
$soaparray=array("location"=>"http://".$host."/".$module."/".$action,"uri"=>$action.".html");
$server= new \SoapServer(null,$soaparray);
$server->setClass(get_class($this));
$server->handle();

}
public function Add($a,$b)
{
return $a+$b;
}
public function testsoap(){
$soap = new \SoapClient(null,array( "location" => "http://yourhost/index/index","uri"=> "index.html", "style" => SOAP_RPC, "use" => SOAP_ENCODED));
echo $soap->Add(1,2);
unset($soap);
}
}

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