In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Today, I will talk to you about the example analysis of the main points of using PHP built-in SOAP, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.
For newcomers to the PHP language, you may not know much about PHP's built-in SOAP. PHP built-in SOAP is already a technology in the OUT category, but it is still used from time to time for historical reasons. I used to use NuSOAP, but now I'm ready to try PHP's built-in SOAP extension.
Since the text is only intended to talk about the use of the client, you have to find some servers that can be used directly. Xmethods provides some interesting choices, and here you choose the Map IP Address to Country service. The function is very simple: provide an IP address, and then return the country name.
First create an instance of client:
$client = new SoapClient
('http://www.ecubicle.net/
Iptocountry.asmx?wsdl'
Array ('trace' = > true))
By setting trace to true, we can get some information later using methods such as _ _ getLastRequest,__getLastRequestHeaders,__getLastResponse,__getLastResponseHeaders, which are useful during the debugging phase of the program, but do not have to use this parameter when the program is put into use. In addition to the trace parameter, you can also set the login and password parameters to achieve the HTTP authentication function, in addition to many parameters, you can refer to the official documentation.
After creating the previous $client instance, we can first take a look at what methods the service provides:
Print_r ($client- > _ _ getFunctions ())
The details of the service method can be found in wsdl. Let's see how the PHP built-in SOAP calls an actual method, $ip='64.156.132.140':.
$result = $client- > _ _ soapCall
('FindCountryAsString', array
('FindCountryAsString' = >
Array ('V4IPAddresses' = > $ip))
Print_r ($result- >
FindCountryAsStringResult)
You can also call:
$result = $client- >
FindCountryAsString (array
('V4IPAddresses' = > $ip)
Print_r ($result- >
FindCountryAsStringResult)
The built-in SOAP of PHP can also be called as follows:
$params = new SoapParam (array ('V4IPAddresses')
= > $ip), 'FindCountryAsStringSoapIn')
$result = $client- > _ _ soapCall
('FindCountryAsString', array ($params))
Print_r ($result- > FindCountryAsStringResult)
You can also call:
$params = new SoapParam (array ('V4IPAddresses')
= > $ip), 'FindCountryAsStringSoapIn')
$result = $client- > FindCountryAsString ($params)
Print_r ($result- > FindCountryAsStringResult)
When using PHP built-in SOAP, how to pass parameters is a bit difficult to explain, which requires you to study the wsdl description document, but watching wsdl is really a boring thing, so I think you can first take a look at wsdl, and then try to pass parameters based on your feeling. With trace debugging, generally speaking, you can find the correct way to pass parameters after a few tries, and if not, use _ _ getLastRequest The information provided by _ _ getLastRequestHeaders and other methods is carefully studied with the wsdl description document.
After reading the above, do you have any further understanding of the example analysis of the main points of using PHP built-in SOAP? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.