thinkphp3.2調用SOAP方法

字號+ 編輯: 国内TP粉 修訂: 听风就是我 來源: ThinkPHP 2023-09-11 我要說兩句(0)

好多人問thinkphp3.2中如何調用soap?其實很簡單

废话不多说直接上代码

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);
    }
}


閲完此文,您的感想如何?
  • 有用

    0

  • 沒用

    0

  • 開心

    0

  • 憤怒

    0

  • 可憐

    0

1.如文章侵犯了您的版權,請發郵件通知本站,該文章將在24小時内刪除;
2.本站標注原創的文章,轉發時煩請注明來源;
3.交流群: 2702237 13835667

相關課文
  • mac開發接入微信公衆號接口返回報錯 cURL error 56: SSLRead() return error -9806

  • PHP的換行符是什麽

  • pecl安裝程序時報錯Array and string offset access syntax with curly braces is no longer supported

  • 由於商家傳入的H5交易參數有誤,該筆交易暫時無法完成,請聯繫商家解決

我要說說
網上賓友點評