Use PHP built-in SOAP key points analysis. Since the text is only intended to talk about the usage of the client, you must first find some servers that can be used directly. Xmethods provides some interesting options. here, select the Map for
Because the text is only intended to talk about the usage of the client, you must first find some servers that can be used directly. Xmethods provides some interesting options. here, select the Map IP Address to Country service, the function is simple, that is, to provide an IP address and then return the country name.
Create a client instance first:
$ Client = new SoapClient
('Http: // www.ecubicle.net/
Iptocountry. asmx? Wsdl ',
Array ('track' => true ));
By setting trace to true, we can use _ getLastRequest ,__ getLastRequestHeaders ,__ getLastResponse ,__ getLastResponseHeaders and other methods later to obtain some information. in the program debugging stage, this information is useful, this parameter is not required when the program is put into use. In addition to the trace parameters, you can also set the login and password parameters to implement HTTP authentication. In addition, there are many parameters that can be found in the official documentation.
After creating the previous $ client instance, let's first look at the methods provided by the service:
Print_r ($ client->__ getFunctions ());
For details about the service method information, refer to the wsdl. let's take a look at how PHP built-in SOAP calls an actual method, $ ip = '64. 156.132.140 ′:
- $result = $client->__soapCall
(’FindCountryAsString’, array
(’FindCountryAsString’ =>
array(’V4IPAddress’ => $ip)));
- print_r($result->
FindCountryAsStringResult);
It can also be called as follows:
- $result = $client->
FindCountryAsString(array
(’V4IPAddress’ => $ip));
- print_r($result->
FindCountryAsStringResult);
PHP built-in SOAP can also be called like this:
- $params = new SoapParam(array(’V4IPAddress’
=> $ip), ‘FindCountryAsStringSoapIn’);
- $result = $client->__soapCall
(’FindCountryAsString’, array($params));
- print_r($result->FindCountryAsStringResult);
It can also be called as follows:
- $params = new SoapParam(array(’V4IPAddress’
=> $ip), ‘FindCountryAsStringSoapIn’);
- $result = $client->FindCountryAsString($params);
- print_r($result->FindCountryAsStringResult);
When using PHP built-in SOAP, it is difficult to explain how to transmit parameters. This requires studying the wsdl description document, but it is really boring to see the wsdl, so I think you can first take a look at the wsdl and then try to pass the parameters based on your feelings, which are used with trace debugging. In general, you can find the correct transmission method after several attempts. if not, the information provided by the _ getLastRequest ,__ getLastRequestHeaders and other methods is carefully studied in combination with the wsdl description document.
Because the text is only intended to talk about the use of the client, you must first find some servers that can be used directly. Xmethods provides some interesting options. Here we select the Map...