PHP uses Nusoap to invoke the Web service's method, Phpnusoap calls the web_php tutorial

Source: Internet
Author: User

PHP uses Nusoap to invoke the Web service's method, Phpnusoap calls the web


This example describes how PHP uses Nusoap to invoke Web services. Share to everyone for your reference. Specific 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 '

Constructor error: '. $err. '

'; 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->c All (' 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 '

Fault: '; Print_r ($result); Echo '

';} else {//Check for errors $err = $client->geterror (); if ($err) {//Display the error echo '

Error: '. $err. '

'; } else {//Display the result echo "
";    Print_r ($result);    echo "
"; }}echo '

Request

'; Echo '
' . Htmlspecialchars ($client->request, ent_quotes). '
'; Echo '

Response

'; Echo '
' . Htmlspecialchars ($client->response, ent_quotes). '
';/*//Display the Debug Messagesecho '

Debug

'; Echo '
' . Htmlspecialchars ($client->debug_str, ent_quotes). '
';*/?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/1034535.html www.bkjia.com true http://www.bkjia.com/PHPjc/1034535.html techarticle PHP uses Nusoap to invoke the Web service's method, Phpnusoap calls the Web This example describes the way PHP uses Nusoap to invoke a Web service. Share to everyone for your reference. Specific as follows: Steps: ...

  • Related Article

    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.