mika34 - 2011-03-12

Hello,

I try to reproduce examples  of this tutorial http://www.codewalkers.com/c/a/Miscellaneous/Using-SOAP-with-PHP/ but I have errors during script execution. I use Ubuntu 10.10 with libnusoap-php distribution's package. There are 2 scripts in the tutorial : stockserver.php and stockclient.php. Stockserver seem to work because I can see the lila box on my web page :
On the other hand, nothing appears when I click on 'WSDL' link but I can see it in firebug and it seems to be not correctly written because of the carriage return on line 2 (after xsd:schema targetNamespace="urn:stockquote):

<?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>

So when I run the client script of the tutorial (you can see it in http://www.codewalkers.com/c/a/Misce…AP-with-PHP/5/) I have a server error with this explanation in Apache error logs :

   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
   PHP Fatal error: Uncaught SoapFault exception:  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

Does anyon knows why ? Thanks for your answers