Soap is already an out-of-scope technology, but for historical reasons, it is often used, used in Nusoap, and is now ready to try out PHP's built-in SOAP extensions. Because the text is only intended to talk about the client's usage, so we have to find some directly use the server, XMethods provides some interesting options, here choose the service, the function is simple, is to provide an IP address, and then return the country name.
Create a client instance first:
$client New Array true));
By setting Trace to true, we can later use the __getlastrequest,__getlastrequestheaders,__getlastresponse,__getlastresponseheaders and other methods to get some information, in the program debugging phase, this information is very useful, when the program is put into use, you do not have to use this parameter. In addition to the trace parameter, you can also set the login and password parameters for HTTP authentication, in addition to many parameters, you can refer to the official documentation.
Once we have created the previous $client instance, we can start by looking at what the services provide:
Print_r ($client->__getfunctions ());
The information details of the service method can be viewed from the WSDL itself, see how to invoke an actual method, $ip = ' 64.156.132.140 ':
$result $client Array Array $ip ))); Print_r ($result->findcountryasstringresult);
You can also call this:
$result $client->findcountryasstring (array$ip)); Print_r ($result->findcountryasstringresult);
You can also call this:
$params New Soapparam (array$ip), ' Findcountryasstringsoapin '); $result $client Array ($params)); Print_r ($result->findcountryasstringresult);
You can also call this:
$params New Soapparam (array$ip), ' Findcountryasstringsoapin '); $result $client->findcountryasstring ($params); Print_r ($result->findcountryasstringresult);
When it comes to using soap, it's a bit of a good idea to read the WSDL description document, but looking at WSDL is a boring thing, so I think you can look at the WSDL first and then try to pass the parameters with the sense, which, in general, Try to find the correct delivery method several times, if not, then through the __getlastrequest,__getlastrequestheaders and other methods provided by the information in conjunction with the WSDL description document carefully studied.
With a very good soap test tool: SOAPUI.