微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

nusoap 客户端无法运行

如何解决nusoap 客户端无法运行

正如标题中所说,我正在尝试制作一个计算器,用户可以在其中输入数字并执行最基本的操作。问题是当我运行它时客户端部分不起作用,屏幕保持空白,我已经检查了库的路由,它们非常好所以我不知道故障在哪里,在这里我附上代码客户端和服务器。

服务器代码

<?PHP

    error_reporting(0);
    include('lib/nusoap.PHP');

    $server = 'MiServicio';
    $servicio = new soap_server();

    $servicio->configureWSDL($server,'urn:servidor');

    $servicio->register("calculadora",array("x" => "xsd:int","y" => "xsd:int"),array("return" => "xsd:string")

    );

    function calculadora($x,$y,$operacion){
        if($operacion == "suma")
            return $x+$y;
        else if($operacion == "suma")
            return $x + $y;
        else if($operacion == "resta")
            return $x - $y;
        else if($operacion == "multiplica")
            return $x * $y;
        else if($operacion == "divide")
            return $x / $y;
        return 0;
      
    }

    $servicio->service(file_get_contents("PHP://input"));

?>

客户端代码

<?PHP

    error_reporting(0);
    include('lib/nusoap.PHP');

    $cliente = new nusoap_client("http://localhost:90/ejercicio3/servidorcaculadora.PHP?wsdl",true);

    $resultado = $cliente -> call("calculadora",array("x"=> '3','y' =>4,'operacion'=>'multiplica'));

    echo($resultado)

?>

解决方法

查看 server.php 时(通过浏览器): enter image description here

您看到 then Input 下缺少 operation

您需要更改此行:

array("x" => "xsd:int","y" => "xsd:int","operation" => "xsd:string"),

在此更改后,可以看到 operation

enter image description here

在您的客户端中,您确实将参数 x 作为字符串 ("x"=> '3') 发送,

为什么不把它作为 int 发送,像这样:"x"=> 3

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。