Home > Backend Development > PHP Tutorial > THINKPHP3.2 solution to using soap to connect to webservice

THINKPHP3.2 solution to using soap to connect to webservice

不言
Release: 2023-03-25 12:40:02
Original
2166 people have browsed it

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);
Copy after login

3. Then call the webservice interface Method

//获取webservice 接口方法

$client->__getFunctions (); 

//获取webservice接口方法的参数类型
$client->__getTypes ();

//执行调用方法

$aryResult = $client->ChangePassword($methodparam);
 var_dump($aryResult);//打印结果
Copy after login

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;
 }
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template