Zend FR

Consultez la FAQ sur le ZF avant de poster une question

Vous n'êtes pas identifié.

#1 24-03-2011 16:06:52

clasie
Nouveau membre
Date d'inscription: 24-03-2011
Messages: 2

Client SOAP: wrong version problème

Bonjour,

   J'aurais besoin d'un peu d'aide pour trouver ce qui cloche dans mon code.

   Environnement: local (ubuntu 10.10), zend 1.10.3, php 5.2.13.

   Problème: En m'inspirant d'un tuto fort simple  (http://code18.blogspot.com/2009/05/cree … -zend.html) j'essaye de faire tourner un service soap et un client pour l'appeler. Les codes server, client et wsdl se trouvent dans mon IndexController et sont listés plus bas.

   Merci pour toute suggestion.
   Clasie.

  Description
  ---------------

1- lorsque je lance le client: http://virgox/public/index/cli -> g une réponse d'erreur:

   Exception information: Message: Wrong Version
   Stack trace:

   #0 /var/www/virgox/library/Zend/Soap/Client.php(1113): SoapClient->__soapCall('getTaxValue', Array, NULL, NULL, Array)
   #1 /var/www/virgox/application/modules/default/controllers/IndexController.php(35): Zend_Soap_Client->__call('getTaxValue', Array)
   #2 /var/www/virgox/application/modules/default/controllers/IndexController.php(35): Zend_Soap_Client->getTaxValue('TPS')
   #3 /var/www/virgox/library/Zend/Controller/Action.php(513): IndexController->cliAction()
   #4 /var/www/virgox/library/Zend/Controller/Dispatcher/Standard.php(289): Zend_Controller_Action->dispatch('cliAction')
   #5 /var/www/virgox/library/Zend/Controller/Front.php(954):    Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
   #6 /var/www/virgox/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
   #7 /var/www/virgox/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
   #8 /var/www/virgox/public/index.php(50): Zend_Application->run()

2- lorsque je pointe sur le wsdl: http://virgox/public/index/wsdl: j'obtiens un wsdl apparemment bien formé:

<definitions name="Example_Tax" targetNamespace="http://virgox/public/index/soap">
<types>
<xsd:schema targetNamespace="http://virgox/public/index/soap"/>
</types>
<portType name="Example_TaxPort">
<operation name="getTaxValue">
<documentation>Return tax value</documentation>
<input message="tns:getTaxValueIn"/>
<output message="tns:getTaxValueOut"/>
</operation>
</portType>
<binding name="Example_TaxBinding" type="tns:Example_TaxPort">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="getTaxValue">
<soap:operation soapAction="http://virgox/public/index/soap#getTaxValue"/>
<input>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://virgox/public/index/soap"/>
</input>
<output>
<soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://virgox/public/index/soap"/>
</output>
</operation>
</binding>
<service name="Example_TaxService">
<port name="Example_TaxPort" binding="tns:Example_TaxBinding">
<soap:address location="http://virgox/public/index/soap"/>
</port>
</service>
<message name="getTaxValueIn">
<part name="type" type="xsd:string"/>
</message>
<message name="getTaxValueOut">
<part name="return" type="xsd:float"/>
</message>
</definitions>

3- lorsque je pointe sur le serveur: http://virgox/public/index/soap: j'obtiens la réponse suivante normale vu que je fais juste que pointer sans rien donner comme données:

<SOAP-ENV:Envelope>
<SOAP-ENV:Body>
<SOAP-ENV:Fault>
<faultcode>Sender</faultcode>
<faultstring>Invalid XML</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



Code
------

class IndexController extends Zend_Controller_Action
{
    public function init()
    {
      $this->getHelper('viewRenderer')->setNoRender(true);
      $this->_helper->layout->disableLayout();
    }

    public function cliAction() //client
    {
        try {
         $client = new Zend_Soap_Client('http://virgox/public/index/wsdl');

         echo 'La TPS est de : ' . $client->getTaxValue('TPS') . ' %';
         echo 'La TVQ est de : ' . $client->getTaxValue('TVQ') . ' %';
        }
        catch(Zend_Exception $e){
         echo $e->getMessage();
        }
    }
    public function wsdlAction() //wsdl
    {
         // inspecter la classe Tax et retourner la description
         $wsdl = new Zend_Soap_AutoDiscover();
         $wsdl->setClass('Example_Tax');
         $wsdl->handle();
    }
    public function soapAction() //server
    {
         // traitement
         $server = new Zend_Soap_Server('http://virgox/public/index/wsdl');
         $server->setClass('Example_Tax');
         $server->handle();
    }
}

- La classe du service est:

class Example_Tax {

/**
* Return tax value
* @param string $type
* @return float
*/
public function getTaxValue($type = 'TPS'){

     if($type == 'TPS'){
         return 5.0;
     }
     elseif ($type == 'TVQ'){
         return 7.5;
     }
     else {
         return 0;
     }
}
}

Dernière modification par clasie (24-03-2011 18:16:59)

Hors ligne

 

#2 25-03-2011 10:31:48

clasie
Nouveau membre
Date d'inscription: 24-03-2011
Messages: 2

Re: Client SOAP: wrong version problème

...suite...

   Si je garde le même code que décrit précédement mais que je fusionne wsdlAction avec soapAction, en modifiant juste l'url d'appel en fonction du changement de code opéré:

    public function soapAction()
    {
        if(isset($_GET['wsdl'])){
         // inspecter la classe Tax et retourner la description
         $wsdl = new Zend_Soap_AutoDiscover();
         $wsdl->setClass('Example_Tax');
         $wsdl->handle();
        }
        else{
         // traitement
         $server = new Zend_Soap_Server('http://virgox/public/index/soap?wsdl');
         $server->setClass('Example_Tax');
         $server->handle();
        }
    }

--- alors cela fonctionne et g la réponse attendue: La TPS est de : 5 %La TVQ est de : 7.5 %

Je ne saisis pas pouquoi.

Merci pour toute suggestions.
Clasie

Hors ligne

 

Pied de page des forums

Propulsé par PunBB
© Copyright 2002–2005 Rickard Andersson
Traduction par punbb.fr

Graphisme réalisé par l'agence Rodolphe Eveilleau
Développement par Kitpages