• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

php实现web服务的方法

php 搞代码 3年前 (2022-01-22) 28次浏览 已收录 0个评论

本篇文章主要介绍php实现web服务的方法,感兴趣的朋友参考下,希望对大家有所帮助。

本文实例讲述了PHP使用NuSOAP调用Web服务的方法,具体如下:

Steps:
1. Download nusoap library from 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 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 fo<mark style="color:transparent">来4源gaodaimacom搞#代%码*网</mark><code>搞代gaodaima码</code>r 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 '<h2>Request</h2>';echo '<pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';echo '<h2>Response</h2>';echo '<pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';/*// Display the debug messagesecho '<h2>Debug</h2>';echo '<pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';*/?>

总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。

相关推荐:

php针对二叉树进行遍历的方法

php+mysql基于Insert Into语句实现数据插入

PHP比较运算符的种类

以上就是php实现web服务的方法的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:php实现web服务的方法

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址