搜索
首页php教程PHP源码PHP 使用 NuSOAP 调用 Web 服务

本文实例讲述了PHP使用NuSOAP调用Web服务的方法。分享给大家供大家参考。具体如下:

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

<?php
 
require_once(&#39;./lib/nusoap.php&#39;);
 
$client = new soapclientnusoap(&#39;http://www.devtrackn.com/webservice/server.php&#39;);
 
$err = $client->getError();
if ($err) {
    // Display the error
    echo &#39;<p><b>Constructor error: &#39; . $err . &#39;</b></p>&#39;;
    // At this point, you know the call that follows will fail
}
 
 
############################
############################
 
 
// update_location method parameter
$param = array(
        &#39;device_number&#39;     => &#39;9910948357&#39;,
        &#39;latitude&#39;          => &#39;40.727757&#39;,
        &#39;longitude&#39;         => &#39;-73.984366&#39;,
        &#39;battery_status&#39;    => &#39;30&#39;
    );
 
// user_action method parameter
$param2 = array(
        &#39;device_number&#39;     => &#39;27ab2026da5213ebd6c95e5fbe50965bdfaddf4b&#39;,
        &#39;latitude&#39;          => &#39;40.727757&#39;,
        &#39;longitude&#39;         => &#39;-73.984366&#39;,
        &#39;user_action&#39;       => &#39;Meeting_Test&#39;
    );
 
// sos method parameter
$param3 = array(
        &#39;device_number&#39;     => &#39;9910948357&#39;,
        &#39;latitude&#39;          => &#39;40.727757&#39;,
        &#39;longitude&#39;         => &#39;-73.984366&#39;,
    );
 
 
 
//$result = $client->call(&#39;update_location&#39;, $param);
//$result = $client->call(&#39;user_action&#39;, $param2);
//$result = $client->call(&#39;sos&#39;, $param3);
$result = $client->call(&#39;user_entity_status&#39;, array(&#39;device_number&#39; => &#39;27ab2026da5213ebd6c95e5fbe50965bdfaddf4b&#39;));
 
 
 
############################
############################
 
 
// Check for a fault
if ($client->fault) {
    echo &#39;<p><b>Fault: &#39;;
    print_r($result);
    echo &#39;</b></p>&#39;;
} else {
    // Check for errors
    $err = $client->getError();
    if ($err) {
        // Display the error
        echo &#39;<p><b>Error: &#39; . $err . &#39;</b></p>&#39;;
    } else {
        // Display the result
        echo "<pre class="brush:php;toolbar:false">";
        print_r($result);
        echo "
"; } } echo '

Request

'; echo '
&#39; . htmlspecialchars($client->request, ENT_QUOTES) . &#39;
'; echo '

Response

'; echo '
&#39; . htmlspecialchars($client->response, ENT_QUOTES) . &#39;
'; /* // Display the debug messages echo '

Debug

'; echo '
&#39; . htmlspecialchars($client->debug_str, ENT_QUOTES) . &#39;
'; */ ?>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器

将Eclipse与SAP NetWeaver应用服务器集成。

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能