soapCall不返回任何值

这是我在PHP中的第一个肥皂代码。 但是我没有任何结果。我认为soapCall和SoapClient中存在一些问题。

我有三个文件。 服务器,客户端和服务。 我想连接到服务器,然后通过肥皂获得学生的名字。这是如此简单的代码,但是不起作用。

//server.php
<?php
class server
{
    public function __construct()
    {

    }

    public function getStudentsname($id_array)
    {
        return 'Mohammad';
    }
}
$params = array('uri'=>'phpsoap/server.php');
$server = new SoapServer(NULL,$params);
$server -> setClass('server');
$server -> handle();

?>

//client.php
<?php 
class client
{
    public function __construct()
    {
        $params = array('location' => 'http://phpsoap.exp/server.php','uri' => 'urn://phpsoap/server.php','trace' => 1
                        );
        $this->instance= new SoapClient(NULL,$params);
    }

    public function getName($id_array)
    {
        $this->instance->__soapCall('getStudentsname',$id_array);
    }
}

$client = new client;
?>

//service.php
<?php

include './client.php';

$id_array=array('id'=>'1');
echo $client->getName($id_array);
?>
gay1718 回答:soapCall不返回任何值

方法client :: getName应该从__soapCall返回值,当前为return void,这就是为什么什么都看不到的原因

public function getName($id_array)
{
    return $this->instance->__soapCall('getStudentsName',$id_array);
}
本文链接:https://www.f2er.com/3167324.html

大家都在问