怎么在PHP中使用NuSOAP调用Web服务

发布时间:2021-03-10 14:40:14 作者:Leah
来源:亿速云 阅读:119

这期内容当中小编将会给大家带来有关怎么在PHP中使用NuSOAP调用Web服务,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

Steps:

1. Download nusoap library from internet.
2. Pass parameter list in your $client->call and enjoy.

<?php
require_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 call that follows will fail
}
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// update_location method parameter
$param = array(
    'device_number'   => '9910948357',
    'latitude'     => '40.727757',
    'longitude'     => '-73.984366',
    'battery_status'  => '30'
  );
// user_action method parameter
$param2 = array(
    'device_number'   => '27ab2026da5213ebd6c95e5fbe50965bdfaddf4b',
    'latitude'     => '40.727757',
    'longitude'     => '-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->call('user_action', $param2);
//$result = $client->call('sos', $param3);
$result = $client->call('user_entity_status', array('device_number' => '27ab2026da5213ebd6c95e5fbe50965bdfaddf4b'));
////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
// Check for a fault
if ($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 '<h3>Request</h3>';
echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h3>Response</h3>';
echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
/*
// Display the debug messages
echo '<h3>Debug</h3>';
echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
*/
?>

上述就是小编为大家分享的怎么在PHP中使用NuSOAP调用Web服务了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 怎么在php中创建类并调用
  2. 怎么在PHP中利用SOAP调用API

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php nusoap web

上一篇:怎么在php中利用反射调用private方法

下一篇:怎么在php项目中调用java程序

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》