您必须构造一个正确的wsdl文件.现在您的服务器以默认的rpc样式运行.尝试使用:http://framework.zend.com/manual/1.12/en/zend.soap.autodiscovery.html具有不同的WSDL绑定样式.
像这样的东西:
server.php:
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_include_path(get_include_path().';./library/;./library/Zend');
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
/* Helper class for my response object */
class CheckVersionResult extends stdClass
{
/** @var bool */
public $ValidationOk = '';
/** @var string */
public $VersionNumber = '';
/** @var string */
public $CurrentRemoteServerTime = '';
}
/* SOAP interface class */
class MySoapClass
{
/**
* Returns version
*
* @param string $param1
* @param string $param2
* @return CheckVersionResult
*/
public function CheckVersion($param1, $param2)
{
$data = new CheckVersionResult();
$data->ValidationOk = 1;
$data->VersionNumber = '1.4.0';
$data->CurrentRemoteServerTime = date('Y-m-d\TH:i:s');
return $data;
}
}
$mySoapClass = new MySoapClass();
if(isset($_GET['wsdl'])) {
$autodiscover = new Zend_Soap_AutoDiscover();
$autodiscover->setClass('MySoapClass');
$autodiscover->setOperationBodyStyle(
array('use' => 'literal',
'namespace' => 'http://localhost/stack/23537231/server.php')
);
$autodiscover->setBindingStyle(
array('style' => 'document',
'transport' => 'http://localhost/stack/23537231/server.php')
);
$autodiscover->handle();
} else {
// pointing to the current file here
$soap = new Zend_Soap_Server("http://localhost/stack/23537231/server.php?wsdl", array(
'cache_wsdl'=> WSDL_CACHE_NONE,
'classmap' => array(
'CheckVersionResult'=>'CheckVersionResult',
)
));
$soap->setClass('MySoapClass');
$soap->handle();
}
client.php
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_include_path(get_include_path().';./library/;./library/Zend');
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->setFallbackAutoloader(true);
/* Helper class for my response object */
class CheckVersionResult extends stdClass
{
/** @var bool */
public $ValidationOk = '';
/** @var string */
public $VersionNumber = '';
/** @var string */
public $CurrentRemoteServerTime = '';
}
$client = new SoapClient('http://localhost/stack/23537231/server.php?wsdl', array(
"trace" => 1, // enable trace to view what is happening
"exceptions" => 1, // disable exceptions
"cache_wsdl" => WSDL_CACHE_NONE,
'classmap' => array(
'CheckVersionResult'=>'CheckVersionResult',
)) // no wsdl
);
$ret = $client->CheckVersion('param1', 'param2');
header('Content-Type: application/xml; charset=utf-8');
echo $client->__getLastResponse();
die();
有了这个我有这个:
true
1.4.0
2014-05-19T22:22:59
旁注:我认为您的回复是有效的肥皂回复.因此,如果客户端是有效的SOAP客户端,它应该能够解析响应并仍然使用它.