PHP built-in SOAP key point analysis-PHP Tutorial-php Tutorial

Source: Internet
Author: User
Tags http authentication
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 ′:

 
 
  1. $result = $client->__soapCall
    (’FindCountryAsString’, array
    (’FindCountryAsString’ =>
    array(’V4IPAddress’ => $ip)));
  2. print_r($result->
    FindCountryAsStringResult);

It can also be called as follows:

 
 
  1. $result = $client->
    FindCountryAsString(array
    (’V4IPAddress’ => $ip));
  2. print_r($result->
    FindCountryAsStringResult);

PHP built-in SOAP can also be called like this:

 
 
  1. $params = new SoapParam(array(’V4IPAddress’
    => $ip), ‘FindCountryAsStringSoapIn’);
  2. $result = $client->__soapCall
    (’FindCountryAsString’, array($params));
  3. print_r($result->FindCountryAsStringResult);

It can also be called as follows:

 
 
  1. $params = new SoapParam(array(’V4IPAddress’
    => $ip), ‘FindCountryAsStringSoapIn’);
  2. $result = $client->FindCountryAsString($params);
  3. 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.