【发布时间】:2016-03-28 09:37:10
【问题描述】:
我使用 nusoap 作为服务文件,这里是我的 service.php
require_once "lib/nusoap.php";
function getProd($category) {
if ($category['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: ".$category['category'];
}
}
$server = new soap_server();
$server->configureWSDL("productlist", "urn:productlist");
$server->register("getProd",
array("category" => "xsd:string"),
array("return" => "xsd:string"),
"urn:productlist",
"urn:productlist#getProd",
"rpc",
"encoded",
"Get a listing of products by category"
);
$post = file_get_contents('php://input');
$server->service($post);
生成的 WSDL 文件 url 是
https://doktormobil.ru/cms/soap/service.php?wsdl
我的client.php是
$client = new SoapClient("https://doktormobil.ru/cms/soap/service.php?wsdl", array('trace' => 1));
$params = array("category" => "books");
$response = $client->getProd($params);
var_dump($client);
var_dump($response);
响应为 NULL,但在 $client->__last_response 中,我从服务中得到了正确的答案。
可能是什么问题?
谢谢。
【问题讨论】:
-
使用您的代码 sn-p,我的响应是
string(41) "No products listed under that category: A"。你确定你没有看错方向吗? -
你使用相同的client.php代码?我的 var_dump($response);此处为空 URL 到 client.php doktormobil.ru/cms/soap/client.php
-
是的,完全相同的代码。
-
是的,当我在另一台服务器上运行 client.php 时确实如此