2011-07-13 8 views
0

私はsymfonyでckWebServicePluginを使用してWebサービスを作成しています。 私は、単純な型のパラメータと複雑な型のメソッドを作ることができました。それはうまくいきましたが、複雑な型の配列をパラメータで取得しようとすると、null値を返すようです。ckWebServicePluginの複合型パラメータの配列は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; 
} 

と、これは

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

私のSOAPクライアントであり、これは私の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; 

答えて

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 ...を行うことを忘れないでください。

0

パラメータが間違っているためです。

$arrRequests != arrRequests 

ckSoapParameterFilterはまだあなたがそれを必要としない$ことなく、簡単なパラメータに@param $ arrRequestsを翻訳します。

それは次のようになります。

public function executeUpdateRequests(sfWebRequest $request) 
{ 
    $res = $request->getParameter('arrRequests'); 
    $this->result = $res; 
    return sfView::SUCCESS; 
} 
関連する問題