The following is an example: Web service is to query whether QQ users online
Using PHP5 to develop clients:
Copy Code code as follows:
<?php
try {
$client = new SoapClient ("helloservice.wsdl", Array (' Encoding ' => ' UTF-8 '));
$client = new SoapClient ("http://webservice.webxml.com.cn/webservices/qqOnlineWebService.asmx?wsdl");
Var_dump ($client->__getfunctions ());
Print ("<br/>");
Var_dump ($client->__gettypes ());
Print ("<br/>");
Class qqcheckonline{
var $qqCode = "10000";
};
$arrPara = Array (new qqcheckonline);
$arrResult = $client->__call ("Qqcheckonline", $arrPara);//$client->qqcheckonline ($arrPara);
Echo $arrResult->qqcheckonlineresult. "<br/>";
catch (SoapFault $e) {
Print $e;
}
?>
The code is really very simple, you can create a SoapClient object, save in the local WSDL file, you can use the remote address, the following array of arrays can take a lot of parameters, specific parameters can check PHP soapclient help, here with the character set code, If you have Chinese in the parameter of the calling method, be sure to specify the character set encoding, or you will get an error.
You can call the SoapClient __geunctions () and __gettypes () methods before calling the Web service to look at the methods, parameters, and data types of the Web service exposure you want to invoke. It is important to note that the incoming parameter names must be consistent with the definition in soapclient, otherwise the parameters are not passed.
You need to use the SoapClient __soapcall () or __call () method to check the Help documentation for PHP. If the parameter requirement is a struct, replace it with a class, such as the code above.
The
also finds a problem, if the Web service method returns an XML-formatted string, and PHP receives its own parsing of the data, rather than an XML string.