开发者

Array of complex type parameters in ckWebServicePlugin are Null

开发者 https://www.devze.com 2023-03-19 17:44 出处:网络
I\'m making a webservice with the ckWebServicePlugin in symfony. I managed to make a method with a simple type in parameter and a complex type in return and it worked well, but when i tried to get an

I'm making a webservice with the ckWebServicePlugin in symfony. I managed to make a method with a simple type in parameter and a complex type in return and it worked well, but when i tried to get an array of complex type in parameter it seems to return me a null value;

/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;
}

and this is my soap client

$test = array(array('request_id' => 1, 'statut' => 3), array('request_id' => 2, 'statut' => 3),);
$result = $proxy->updateRequests($test);

and this is my RequestShort type

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;
}
}

and finally, my 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:开发者_如何学JAVA RequestShort
        RequestShortArray: ckGenericArray

How comes the code below returns nothing ?

$res = $request->getParameter('$arrRequests');
$this->result = $res;


Seems to me that in:

$res = $request->getParameter('$arrRequests');
$this->result = $res;
return sfView::SUCCESS;

You misspelled the parameter for getParameter() function.

Perhaps it should be something like:

$res = $request->getParameterHolder()->getAll();
$this->result = $res;
return sfView::SUCCESS;

And don't forget to do a symfony cc && symfony webservice:generate-wsdl ... just in case.


It's because you are getting the wrong parameter.

$arrRequests != arrRequests

ckSoapParameterFilter already translate the @param $arrRequests to the simple parameter without the $ so you don't need it.

it should be:

public function executeUpdateRequests(sfWebRequest $request)
{
   $res = $request->getParameter('arrRequests');
   $this->result = $res;
   return sfView::SUCCESS;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号