Home >Backend Development >PHP Tutorial >THINKPHP3.2 solution to using soap to connect to webservice_php example
THINKPHP3.2 can be used as an introductory framework, which is relatively simple to use, easy to understand and easy to learn. This article mainly introduces in detail the solution of THINKPHP3.2 using soap to connect to webservice. Today I use THINKPHP3.2 to use soap to connect to webservice when developing in the framework. Let me share some insights.
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; } }
above That’s all the content of this article. I hope it can be helpful to the students.
Related recommendations:
TP3.2 realizes switching between the previous and next chapters
Solution to the problem of conflicts with the same name when batch uploading in TP3.2
The above is the detailed content of THINKPHP3.2 solution to using soap to connect to webservice_php example. For more information, please follow other related articles on the PHP Chinese website!