How PHP Implements Web services

Source: Internet
Author: User
This article mainly introduces PHP implementation of Web services methods, interested in the reference of friends, I hope to be helpful to everyone.

This example describes how PHP uses Nusoap to invoke a Web service, as follows:

Steps:
1. Download Nusoap Library from the Internet.
2. Pass parameter list in your $client->call and enjoy.

<?phprequire_once ('./lib/nusoap.php '); $client = new Soapclientnusoap (' http://www.devtrackn.com/webservice/  Server.php '); $err = $client->geterror (); if ($err) {//Display the error echo ' <p><b>constructor error: ' . $err.  ' </b></p> '; At this point, you know the follows would fail}//////////////////////////////////////////////////////////////   Update_location Method Parameter$param = Array (' Device_number ' = ' 9910948357 ', ' latitude ' = ' 40.727757 ', ' longitude ' = ' -73.984366 ', ' Battery_status ' =&gt ; ' + ');//User_action Method parameter$param2 = Array (' device_number ' = ' 27ab2026da5213ebd6c95e5fbe50965bdfaddf  4b ', ' latitude ' = ' 40.727757 ', ' longitude ' and ' -73.984366 ', ' user_action ' = ' meeting_test '    ///sos Method PARAMETER$PARAM3 = Array (' device_number ' = ' 9910948357 ', ' latitude ' = ' 40.727757 ',' Longitude ' = ' -73.984366 ',);//$result = $client->call (' update_location ', $param);//$result = $client->cal L (' user_action ', $param 2);//$result = $client->call (' SOS ', $param 3); $result = $client->call (' User_entity_ Status ', Array (' device_number ' = ' 27ab2026da5213ebd6c95e5fbe50965bdfaddf4b '));/////////////////////////////// Check for a faultif ($client-  >fault) {echo ' <p><b>fault: ';  Print_r ($result); Echo ' </b></p> ';}  else {//Check for errors $err = $client->geterror (); if ($err) {//Display the error echo ' <p><b>error: '. $err.  ' </b></p> ';    } else {//Display the result echo "<pre>";    Print_r ($result);  echo "</pre>"; }}echo ' 

Summary : The above is the entire content of this article, I hope to be able to help you learn.

Related recommendations:

PHP traversal method for binary tree

Php+mysql data insertion based on INSERT INTO statement

Types of PHP comparison operators

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.