如何使用thinkphp3.2 框架中开发时使用soap连接webservice ?本文主要为大家详细介绍了thinkphp3.2使用soap连接webservice的解决方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。
1.首先我们要在php.ini 中开启一下
php_openssl.dll
php_soap.dll

立即学习“PHP免费学习笔记(深入)”;
2.在方法中创建的 SoapClient 类 的实例
$url="https://www.test.com/adwebservice.asmx?wsdl"; $client = new \SoapClient($url);
3.然后调用webservice 接口方法
//获取webservice 接口方法 $client->__getFunctions (); //获取webservice接口方法的参数类型 $client->__getTypes (); //执行调用方法 $aryResult = $client->ChangePassword($methodparam); var_dump($aryResult);//打印结果
4.完整代码如下
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;
}
}大家学会了吗?赶紧动手尝试一下吧。
相关推荐:
以上就是thinkPHP3.2如何用soap连接webservice方法的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号