【问题标题】:Error using NuSOAP webservice client使用 NuSOAP Web 服务客户端时出错
【发布时间】:2017-07-18 09:11:04
【问题描述】:

在 php.ini 中使用 NuSOAP 时,我遇到了“HTTP 错误:未找到不支持的 HTTP 响应状态 404(soapclient->response 具有响应内容)”的问题。这是服务器的代码:

<?php
require_once "nusoap.php";

function getProd($category) {
    if ($category == "books") {
        return join(",", array(
            "The WordPress Anthology",
            "PHP Master: Write Cutting Edge Code",
            "Build Your Own Website the Right Way"));
    }
    else {
        return "No products listed under that category";
    }
}

$server = new soap_server();
$server->register("getProd");

$server->service($HTTP_RAW_POST_DATA);

这是客户端请求的代码:

<?php
require_once "nusoap.php";
$client = new nusoap_client("http://localhost/nusoap/productlist.php");

$error = $client->getError();
if ($error) {
    echo "<h2>Constructor error</h2><pre>" . $error . "</pre>";
}

$result = $client->call("getProd", array("category" => "books"));

if ($client->fault) {
    echo "<h2>Fault</h2><pre>";
    print_r($result);
    echo "</pre>";
}
else {
    $error = $client->getError();

    if ($error) {
        echo "<h2>Error</h2><pre>" . $error . "</pre>";
    }

    else {
        echo "<h2>Books</h2><pre>";
        echo $result;
        echo "</pre>";
    }
}

【问题讨论】:

    标签: php html soap nusoap


    【解决方案1】:

    我输入了错误的网址 $client = new nusoap_client("http://localhost/nusoap/productlist.php"); 我将其更改为: $client = new nusoap_client("http://localhost/testcases/nusoap/productlist.php"); 现在它工作正常。

    【讨论】:

      【解决方案2】:

      响应状态 404 导致的错误通常是由于 url 路径不正确造成的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-04
        • 2013-04-23
        相关资源
        最近更新 更多