Bonjour,
Tout est dans le titre : j'essaie de réaliser pas-à-pas ce tutoriel http://www.codewalkers.com/c/a/Misce...SOAP-with-PHP/ au demeurant très pédagogique mais j'obtiens toujours la même erreur dans les logs d'Apache lors de l'exécution d'un des scripts
En gros je travaille sur une Ubuntu 10.10 et j'installe le paquet libnusoap-php avec synaptic.
Ensuite j'execute le script qu'on peut voir sur cette page en y mettant les bons include. Ce qui donne le script :
script qui à l'air de fonctionner puisque je vois la petite boite lila de nusoap
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 ?php function getStockQuote($symbol) { mysql_connect('localhost','root','abc123'); mysql_select_db('soaptest1'); $query = "SELECT stock_price FROM stockprices " . "WHERE stock_symbol = '$symbol'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); return $row['stock_price']; } ini_set("soap.wsdl_cache_enabled", "0"); require('nusoap/nusoap.php'); $server = new soap_server(); $server->configureWSDL('stockserver', 'urn:stockquote'); $server->register("getStockQuote", array('symbol' => 'xsd:string'), array('return' => 'xsd:decimal'), 'urn:stockqote', 'urn:stockquote#getStockQuote', 'rpc', 'encoded', 'Get stock quote'); $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA);
Par contre quand je clique sur le lien WSDL rien n'apparait mais je peux quand même observer le WSDL dans l'onglet réseau de firebug et il semble que la balise de la ligne 2 ne soit pas correctement écrite puisque le caractère '>' est placé après un passage à la ligne (voyez la balise xsd:schema targetNamespace="urn:stockquote")
Du coup quand j'exécute le script client (http://www.codewalkers.com/c/a/Misce...AP-with-PHP/5/) il y a une erreur 500 avec ce message dans les logs d'Apache :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35<?xml version="1.0" encoding="ISO-8859-1"?> <definitions xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="urn:stockquote" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="urn:stockquote"> <types> <xsd:schema targetNamespace="urn:stockquote" > <xsd:import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> <xsd:import namespace="http://schemas.xmlsoap.org/wsdl/" /> </xsd:schema> </types> <message name="getStockQuoteRequest"> <part name="symbol" type="xsd:string" /></message> <message name="getStockQuoteResponse"> <part name="return" type="xsd:decimal" /></message> <portType name="stockserverPortType"> <operation name="getStockQuote"> <documentation>Get stock quote</documentation> <input message="tns:getStockQuoteRequest"/> <output message="tns:getStockQuoteResponse"/> </operation> </portType> <binding name="stockserverBinding" type="tns:stockserverPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="getStockQuote"> <soap:operation soapAction="urn:stockquote#getStockQuote" style="rpc"/> <input><soap:body use="encoded" namespace="urn:stockqote" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></input> <output><soap:body use="encoded" namespace="urn:stockqote" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/></output> </operation> </binding> <service name="stockserver"> <port name="stockserverPort" binding="tns:stockserverBinding"> <soap:address location="http://localhost/private/soaptest1/stockserver.php"/> </port> </service> </definitions>
Donc je suis preneur d'éventuels retours d'expérience sur ce genre d'erreur de nusoap. Des idées ?[Sat Mar 12 18:34:58 2011] [error] [client 127.0.0.1] PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/private/soaptest1/stockserver.php' : Premature end of data in tag html line 2\n in /media/www-dev/private/soaptest1/stockclient.php on line 4
[Sat Mar 12 18:34:58 2011] [error] [client 127.0.0.1] PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/private/soaptest1/stockserver.php' : Premature end of data in tag html line 2\n in /media/www-dev/private/soaptest1/stockclient.php:4\nStack trace:\n#0 /media/www-dev/private/soaptest1/stockclient.php(4): SoapClient->SoapClient('http://localhos...')\n#1 {main}\n thrown in /media/www-dev/private/soaptest1/stockclient.php on line 4
Partager