我使用nusoap作为服务文件这里是我的服务.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
我的客户.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中,我从Service得到了正确的答案。
问题出在哪里?
谢谢。
好!我处理这个。正如F0G所注意到的,他和我的结果不同。问题是PHP缓存了我的WSDL文件。当我把
ini_set("soap.wsdl_cache_enabled", "0");
一切顺利。非常感谢。