Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1102 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  [fixed]Problème avec Zend_Soap_Server

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[fixed]Problème avec Zend_Soap_Server

n°2008221
Profil sup​primé
Posté le 09-07-2010 à 10:20:55  answer
 

Je suis en train de __tenter__ de faire tourner un serveur soap avec zend sans succès.
J'ai tout retiré du projet dans des fichiers séparés pour éviter les effets de bord.
 
Voici la bête:
 
fichier wsdl.php:

Code :
  1. <?php
  2. function wsdl(){
  3. $uri = "http://localhost/webservice/server.php";
  4. $autodiscover = new Zend_Soap_AutoDiscover(true,$uri);
  5. $autodiscover->setClass('Business');
  6. $autodiscover->handle();
  7. }
  8. class Business{
  9. /**
  10.  * hello function
  11.  * @return string
  12.  */
  13. public function hello(){
  14.  return 'world';
  15. }
  16. }
  17. wsdl();


Si j'exécute le code, ça me sort un xml qui me semble correct:

Code :
  1. <definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://localhost/webservice/server.php" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Business" targetNamespace="http://localhost/webservice/server.php"><types><xsd:schema targetNamespace="http://localhost/webservice/server.php"/></types><portType name="BusinessPort"><operation name="hello"><documentation>hello function</documentation><input message="tns:helloIn"/><output message="tns:helloOut"/></operation></portType><binding name="BusinessBinding" type="tns:BusinessPort"><soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/><operation name="hello"><soap:operation soapAction="http://localhost/webservice/server.php#hello"/><input><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/webservice/server.php"/></input><output><soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost/webservice/server.php"/></output></operation></binding><service name="BusinessService"><port name="BusinessPort" binding="tns:BusinessBinding"><soap:address location="http://localhost/webservice/server.php"/></port></service><message name="helloIn"/><message name="helloOut"><part name="return" type="xsd:string"/></message></definitions>


 
Fichier server.php:

Code :
  1. <?php
  2. function server(){
  3. $wsdl = 'http://localhost/webservice/wsdl.php';
  4. $options = array('soap_version' => SOAP_1_2);
  5. $server = new Zend_Soap_Server();
  6. $server->setWsdl($wsdl);
  7. $server->setOptions($options);
  8. $server->handle();
  9. }
  10. server();


Si j'exécute ce code, il me sort un XML bizarre:

Code :
  1. <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>


Bon je trouve ça bizarre.  
Bien que ça n'a pas vraiment de sens d'ouvrir cette page avec un browser.
 
Le pire est dans le fichier client.php:

Code :
  1. <?php
  2. function client(){
  3. $wsdl = 'http://localhost/webservice/wsdl.php';
  4. $options = array('soap_version' => SOAP_1_2);
  5. $localService = new SoapClient($wsdl,$options);
  6. $localService = new Zend_Soap_Client($wsdl,$options);
  7. print($localService->hello());
  8. }
  9. client();


ceci me génère une erreur fatal:

Code :
  1. [09-Jul-2010 08:06:30] PHP Fatal error:  Function 'hello' doesn't exist in C:\wamp\www\Zend\Soap\Server.php on line 830
  2. [09-Jul-2010 08:06:30] PHP Stack trace:
  3. [09-Jul-2010 08:06:30] PHP   1. {main}() C:\wamp\www\webservice\server.php:0
  4. [09-Jul-2010 08:06:30] PHP   2. server() C:\wamp\www\webservice\server.php:18
  5. [09-Jul-2010 08:06:30] PHP   3. Zend_Soap_Server->handle($request = *uninitialized*) C:\wamp\www\webservice\server.php:15
  6. [09-Jul-2010 08:06:30] PHP   4. SoapServer->handle('<?xml version="1.0" encoding="UTF-8"?>\n<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://localhost/webservice/server.php" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:enc="http://www.w3.org/2003/05/soap-encoding"><env:Body><ns1:hello env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"/></env:Body></env:Envelope>\n') C:\wamp\www\Zend\Soap\Server.php:830


 
Est-ce qu'il y a quelque chose que je fais mal ?
Note que je suis obligé de travaillé avec un fichier wsdl. De toute façon, j'ai essayé sans et ça me met toujours la même erreur.


Message édité par Profil supprimé le 09-07-2010 à 10:39:20
mood
Publicité
Posté le 09-07-2010 à 10:20:55  profilanswer
 

n°2008232
Profil sup​primé
Posté le 09-07-2010 à 10:38:50  answer
 

Haaaa j'ai trouvé.
 
Il faut faire un $server->setClass('Business'); pour le server aussi  [:cloud_]


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  [fixed]Problème avec Zend_Soap_Server

 

Sujets relatifs
Problème d'arrayProblème imbrication d'objet Jquery IE
Problème de montage des lecteurs réseaux sous windows 7Probleme de compilation
Problème type encodage ("é","è") etc..[RESOLU] Problème tableau php -> javascript
Problème namespacesProbleme tableau multidimensionnel
probleme caracteres UNIX-WINDOWS en php(résolu) Probleme avec IDLE (manque un onglet)
Plus de sujets relatifs à : [fixed]Problème avec Zend_Soap_Server


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR