This article mainly introduces in detail the solution for THINKPHP3.2 to use soap to connect to webservice. It has certain reference value. Interested friends can refer to it
Use THINKPHP3.2 framework today Use soap to connect to webservice during development. Let me share some insights now,
1. First we need to open it in php.ini
php_openssl.dll
php_soap.dll
2. Create an instance of the SoapClient class in the method
$url="https://www.test.com/adwebservice.asmx?wsdl"; $client = new \SoapClient($url);
3. Then call the webservice interface Method
//获取webservice 接口方法 $client->__getFunctions (); //获取webservice接口方法的参数类型 $client->__getTypes (); //执行调用方法 $aryResult = $client->ChangePassword($methodparam); var_dump($aryResult);//打印结果
4. The complete code is as follows
class WebseviceSoap { public function WebService($url,$methodparam=array()){ try{ header("content-type:text/html;charset=UTF-8"); $client = new \SoapClient($url); //$client->__getFunctions (); //$client->__getTypes (); // 参数转为数组形式传 // 调用远程函数 $aryResult = $client->ChangePassword($methodparam); return (array)$aryResult; }catch(Exception $e){ $aryResult=""; } return $aryResult; } }
Related recommendations:
thinkphp3.2 implements the method of calling other modules across controllers
thinkphp3.2.3 integrates phpExcel export data
The above is the detailed content of THINKPHP3.2 solution to using soap to connect to webservice. For more information, please follow other related articles on the PHP Chinese website!