这期内容当中小编将会给大家带来有关怎么在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服务了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。