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 :
- <?php
- function wsdl(){
- $uri = "http://localhost/webservice/server.php";
- $autodiscover = new Zend_Soap_AutoDiscover(true,$uri);
- $autodiscover->setClass('Business');
- $autodiscover->handle();
- }
- class Business{
- /**
- * hello function
- * @return string
- */
- public function hello(){
- return 'world';
- }
- }
- wsdl();
|
Si j'exécute le code, ça me sort un xml qui me semble correct:
Code :
- <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 :
- <?php
- function server(){
- $wsdl = 'http://localhost/webservice/wsdl.php';
- $options = array('soap_version' => SOAP_1_2);
- $server = new Zend_Soap_Server();
- $server->setWsdl($wsdl);
- $server->setOptions($options);
- $server->handle();
- }
- server();
|
Si j'exécute ce code, il me sort un XML bizarre:
Code :
- <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 :
- <?php
- function client(){
- $wsdl = 'http://localhost/webservice/wsdl.php';
- $options = array('soap_version' => SOAP_1_2);
- $localService = new SoapClient($wsdl,$options);
- $localService = new Zend_Soap_Client($wsdl,$options);
- print($localService->hello());
- }
- client();
|
ceci me génère une erreur fatal:
Code :
- [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
- [09-Jul-2010 08:06:30] PHP Stack trace:
- [09-Jul-2010 08:06:30] PHP 1. {main}() C:\wamp\www\webservice\server.php:0
- [09-Jul-2010 08:06:30] PHP 2. server() C:\wamp\www\webservice\server.php:18
- [09-Jul-2010 08:06:30] PHP 3. Zend_Soap_Server->handle($request = *uninitialized*) C:\wamp\www\webservice\server.php:15
- [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