ckWebServicePlugin call returns stdClass instead of my class

Ask help about existing plugins, or find advice about the way to build up your own.

Moderators: dwhittle, Ian

ckWebServicePlugin call returns stdClass instead of my class

Postby ventzy » Wed Oct 05, 2011 12:30 am

First, I want to thank the devs of ckWebServicePlugin for their work. Really useful plugin.

I want to define function that returns instance of my simple class.
The function is getPartner, result object class is CmsPartnerData. As result I get stdClass instance instead of CmsPartnerData. Returned object has right content, just its not the desired class. I have CmsPartnerData definition on the server and the client.

Action:
Code: Select all
  /**
   * Get Partner
   *
   * @WSMethod(name='getPartner', webservice='Api')
   *
   * @param string $serviceType
   * @return CmsPartnerData
   *
   */
  public function executeGetPartner(sfWebRequest $request) {
    $p = new CmsPartnerData();
    $p->name = 'My Partner';
     
    $this->result = $p;
   
    return sfView::SUCCESS;
  }


Result class definition:
Code: Select all
class CmsPartnerData {
   /**
   * @var string
   */ 
  public $name = 'partner';

  function test() {
    return 'test result';
  }
}


module.yml
Code: Select all
soap:
  getPartner: { parameter: [serviceType], result: { class: ckPropertyResultAdapter, param: { property: result } } }


app.yml
Code: Select all
soap:
  enable_soap_parameter: on
  ck_web_service_plugin:
    wsdl: '%SF_WEB_DIR%/Api.wsdl'
    handler: ApiHandler
    soap_options:
      classmap:   
        CmsPartnerData: CmsPartnerData


Client:
Code: Select all
  public function executeTest(sfWebRequest $request) {
    $api = new SoapClient('http://api.local/Api.wsdl');

    //check class existence - its ok
    $dummy = new CmsPartnerData();
   
    $partner = $api->getPartner('test');

    dump($partner);   
  }


Dump result:
Code: Select all
object(stdClass)[125]
  public 'name' => string 'My Partner' (length=10)
....
ventzy
Member
 
Posts: 30
Joined: Fri Jun 27, 2008 2:23 pm

Return to General plug-ins

Who is online

Users browsing this forum: No registered users and 2 guests