THINKPHP3.2 use soap to connect to webservice,
I will share some notes on using soap to connect to webservice during THINKPHP3.2 development today,
1. First, we need to enable it in php. ini.
Php_openssl.dll
Php_soap.dll
2. SoapClient class instance created in the Method
$url="https://www.test.com/adwebservice.asmx?wsdl";$client = new \SoapClient($url);
3. Call the webservice interface method.
// Obtain the webservice Interface Method $ client->__ getFunctions (); // obtain the parameter type of the webservice Interface Method $ client->__ getTypes (); // execute the call method $ aryResult = $ client-> ChangePassword ($ methodparam); var_dump ($ aryResult); // print the result
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 (); // convert the parameter to an array. // call the remote function $ aryResult = $ client-> ChangePassword ($ methodparam); return (array) $ aryResult;} catch (Exception $ e) {$ aryResult = "";} return $ aryResult ;}}
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.