0

symfony で ckWebServicePlugin を使用して Web サービスを作成しています。単純な型のパラメーターと複雑な型の戻り値を使用してメソッドを作成することができましたが、うまく機能しましたが、パラメーターの複雑な型の配列を取得しようとすると、null 値が返されるようです。

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

2 に答える 2

1

私には次のように思えます:

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

関数のパラメーターのスペルが間違っていますgetParameter()

おそらくそれは次のようなものでなければなりません:

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

そして、万が一に備えて行うことを忘れないでくださいsymfony cc && symfony webservice:generate-wsdl ...

于 2012-04-02T17:43:53.270 に答える
0

間違ったパラメータを取得しているためです。

$arrRequests != arrRequests

ckSoapParameterFilterはすでに@param $arrRequestsを$なしの単純なパラメーターに変換しているため、必要ありません。

そのはず:

public function executeUpdateRequests(sfWebRequest $request)
{
   $res = $request->getParameter('arrRequests');
   $this->result = $res;
   return sfView::SUCCESS;
}
于 2014-04-22T22:23:50.930 に答える