Monday, June 29, 2009

Re: Models and SOAP

Thats what I thought too, but when I do that I get an error that the
SoapModel class cannot be found.

class SoapModel extends AppModel
{
public function __construct()
{
parent::__construct();

$api_config = Configure::read('API');

$this->TransactionParams['loginName'] = $api_config
['loginName'];
$this->TransactionParams['loginPassword'] = $api_config
['loginPassword'];
$this->TransactionParams['orgName'] = $api_config['orgName'];

$this->TransactionParams['transaction']['id'] = date('d-m-y-
i:s:a').' - ';
$this->TransactionParams['transaction']['wait'] = $api_config
['wait'];
$this->TransactionParams['transaction']['version'] =
$api_config['version'];
$this->TransactionParams['transaction']
['TransactionCommandList'] = array ();
}
}

class Subscriber extends SoapModel
{
/**
* @var useDbConfig
* @description The name of the DataSource connection that this
Model uses. Defined in core/database.php
*/
public $useDbConfig = 'soap';
public $useTable = false;

public $TransactionParams = array ();

public function __construct()
{
parent::__construct();
}

}


Both these files are in the app/models directory.


Steve


On Jun 29, 12:58 pm, Carlos Gonzalez Lavin <carloslavi...@gmail.com>
wrote:
> How about a little class hierarchy?
>
> Soap extends AppModel and Suscriber-Device extend Soap
>
> You put that in Soap's constructor and then just super() it in
> Suscriber-Device
>
> 2009/6/29 RhythmicDevil <rhythmicde...@gmail.com>
>
>
>
> > Hi,
> > some of my application's models will use SOAP or MySQL. I am trying to
> > figure out where to put the common SOAP stuff.
>
> > User Model will use MySQL
> > Subscriber Model will use SOAP
> > Device Model will use SOAP
>
> > In my SOAP models I need to have this:
>
> >        $api_config = Configure::read('API');
>
> >        $this->TransactionParams['loginName'] = $api_config
> > ['loginName'];
> >        $this->TransactionParams['loginPassword'] = $api_config
> > ['loginPassword'];
> >        $this->TransactionParams['orgName'] = $api_config['orgName'];
>
> >        $this->TransactionParams['transaction']['id'] = date('d-m-y-
> > i:s:a').' - ';
> >        $this->TransactionParams['transaction']['wait'] = $api_config
> > ['wait'];
> >        $this->TransactionParams['transaction']['version'] =
> > $api_config['version'];
> >        $this->TransactionParams['transaction']
> > ['TransactionCommandList'] = array ();
>
> > Currently this sits in the constructor for Subscriber but I know thats
> > wrong as I would then have to repeat that for each subsequent model
> > that uses SOAP. I am using this for my datasource:
>
> >http://www.pagebakers.nl/2008/12/18/soapsource-a-soap-client-datasour...
>
> > I thought a behavior would be the trick but I am not sure. The docs
> > dont seem to point in that direction.
> > I dont want to extend app_model because that would then add it to the
> > models that use MySQL.
>
> > Any ideas?
>
> > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: