我正在用symfony中的ckWebServicePlugin制作webservice。 我设法使用一个简单的参数类型和一个复杂的类型作为回报的方法,它运作良好,但是当我试图在参数中获取一个复杂类型的数组时,它似乎返回一个空值;ckWebServicePlugin中的复杂类型参数数组是空的
/api/actions.class.php
/** Allow to update request
*
* @WSMethod(name='updateRequests', webservice='api')
*
* @param RequestShort[] $arrRequests
*
* @return RequestShort[] $result
*/
public function executeUpdateRequests(sfWebRequest $request)
{
$res = $request->getParameter('$arrRequests');
$this->result = $res;
return sfView::SUCCESS;
}
,这是我的SOAP客户端
$test = array(array('request_id' => 1, 'statut' => 3), array('request_id' => 2, 'statut' => 3),);
$result = $proxy->updateRequests($test);
,这是我RequestShort型
class RequestShort {
/**
* @var int
*/
public $request_id;
/**
* @var int
*/
public $statut;
public function __construct($request_id, $statut)
{
$this->request_id = $request_id;
$this->statut = $statut;
}
}
最后,我的app.yml
soap:
# enable the `ckSoapParameterFilter`
enable_soap_parameter: on
ck_web_service_plugin:
# the location of your wsdl file
wsdl: %SF_WEB_DIR%/api.wsdl
# the class that will be registered as handler for webservice requests
handler: ApiHandler
soap_options:
classmap:
# mapping of wsdl types to PHP types
RequestShort: RequestShort
RequestShortArray: ckGenericArray
下面的代码如何返回什么?
$res = $request->getParameter('$arrRequests');
$this->result = $res;