| For everyone to introduce a PHP call WebService example, query QQ users online, have the need for friends, you can refer to the next. Example, PHP developed by the client program called WebService.
' UTF-8 '); $client = new SoapClient ("http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl"); Var_dump ($client->__getfunctions ());p rint (" "), Var_dump ($client->__gettypes ());p rint (" "), class Qqcheckonline{var $qqCode =" 10000 ";}; $arrPara = Array (new Qqcheckonline), $arrResult = $client->__call ("Qqcheckonline", $arrPara);//$client Qqcheckonline ($arrPara); Echo $arrResult->qqcheckonlineresult. " ";} catch (SoapFault $e) {print $e;}? >
Description: When creating the SoapClient object, can be saved in the local WSDL file, you can use the remote address, the following array can take a lot of parameters, the specific parameters can be found in PHP soapclient help, here with the character set encoding, If you have Chinese in the parameters of the calling method, be sure to specify the character set encoding, or else an error will occur. Before invoking the Web service, you can call SoapClient's __geunctions () and __gettypes () methods to see the methods, parameters, and data types that you want to invoke for the Web service exposure, It is important to note that the parameter names passed in must be consistent with the definitions in the SoapClient, otherwise the parameters will not pass through. You need to use SoapClient's __soapcall () or __call () method to check the PHP Help documentation. If the parameter requirement is a struct, replace it with a class, such as the code above. Issue: If the Web service method returns an XML-formatted string, PHP will then parse the data itself, rather than the XML string, when it receives it. In the practical application, we should pay more attention to this point. |