Home >Backend Development >PHP Tutorial >Example reference of how to call webservice in PHP_PHP tutorial
The following is an example: the web service is to query whether QQ users are online
Develop the client using php5:
class qqCheckOnline{
var $qqCode = "10000";
};
$arrPara = array(new qqCheckOnline);
} catch (SOAPFault $e) {
print $e;
}
?>
The code is really simple, right? When creating a SoapClient object, you can use a WSDL file saved locally or a remote address. The following array can contain many parameters. For specific parameters, you can check the SoapClient help of php. Here is the character set encoding. If If there are Chinese characters in the parameters of the calling method, the character set encoding must be specified, otherwise an error will occur.
Another problem I found is that if the web service method returns a string in XML format, PHP will parse the data content by itself after receiving it, not the XML string.