php wsdl response,PHP Soap Server响应格式

您必须构造一个正确的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客户端,它应该能够解析响应并仍然使用它.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值