Hi,
I have an application that uses SoapSource for one of its datasources.
The Web Service that I am using only defines one method:
sendTransaction. The data set that is sent to this method includes an
element called TransactionCommand that contains a string that
represents the actual command I want to run on the server. For
instance:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/
envelope/" xmlns:ns1="http://www.etisoftware.com/wsi18n";>
<SOAP-ENV:Body><ns1:sendTransaction>
    <loginName>webapp</loginName>
    <loginPassword>s0l0pw0rd</loginPassword>
    <orgName>works</orgName>
    <transaction>
        <id>09-02-11-58:51:am - QueryLocale</id>
        <wait>0</wait>
        <version>3.2</version>
        <TransactionCommandList>
            <TransactionCommand>
                <QueryLocale>
                      <localeNbr>1</localeNbr>
               </QueryLocale>
           </TransactionCommand>
       </TransactionCommandList>
</transaction>
</ns1:sendTransaction>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


The method that I am actually running is QueryLocale. I used to have
one model file per web service (we have about 5 of these) and each
method in the model mapped to one of the TransactionCommands. I
recently updated SoapSource to add the extra parameters I need to
build the SOAP packet and I can use find() and read() on the models
and I dont have to map the TransactionCommands. So now my model looks
more like this:


class Epg extends AppModel
{

    public $useDbConfig = 'epg_soap';
    public $useTable = false;

    public function find($method, $params)
    {
        $this->responseKeys = $params['responseKeys'];
        return $this->afterFind($this->query('sendTransaction',
$params['conditions'], $method), true);
    }

    public function afterFind($results, $primary)
    {
        return $results->transactionResult->{$this->responseKeys[0]}-
>{$this->responseKeys[1]};
    }
}


$method is a string that represents a TransactionCommand.



Is there a better way to do this? I cannot change the Web Service. Do
you see any gotchas in what I am doing?

Thanks.

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to