|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-08-11 19:30 UTC] richard at rjharrison dot org
Description: ------------ SoapServer is failing on construction. I pass an URL with *valid* WSDL xml, which is generated automatically. - If I save the WSDL locally and load from disk it works. - If I serve the WSDL remotely from a static .xml file it works. - If I load the WSDL-url in my browser I get a well-formed XML response. - I can access the dodgy-wsdl URL via file_get_contents. - Using 5.2.6 on another machine it works fine. I inspected the http requests and think it could be related to chunked encoding (it fails on the chunked encoding response). Reproduce code: --------------- <?php $url = 'http://myserver/path?wsdl'; $serv = new SoapServer($url); ?> I can probably provide a sample url privately. Expected result: ---------------- $serv to be instantiated Actual result: -------------- SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://myserver/path?wsdl' : Premature end of data in tag definitions line 2 Below are the headers of the response that fails:- Date: Tue, 11 Aug 2009 19:15:29 GMT Server: Apache/2.2.8 (Unix) DAV/2 PHP/5.3.0 X-powered-by: PHP/5.3.0 Vary: Accept-Encoding,User-Agent Connection: close Transfer-encoding: chunked Content-type: text/xml PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
@sjoerd, When I load the WSDL over HTTP there is no content-length header, as the response is sent chunk-encoded. As stated in the original report, if I save the WSDL to disk then it works, for example:- <?php $data = file_get_contents('http://myserver/path?wsdl'); file_put_contents("wsdl.xml", $data); $serv = new SoapServer("wsdl.xml"); // works ?> @stig, The behaviour you describe with different size WSDL might backup the theory that it's chunk-encoding related. With a small body size, I think PHP *does* send a content-length header; but if the body is larger than the output buffer (?) it will switch to chunk-encoding to allow for the unknown, variable length.The service works when using a local file. I did some more tests, and have identified the actual problem. Its not in the PHP 5.3 release, rather its a "bug" in the Zend AutoDiscover class provided by Zend. I assume the reporter also might be using this to generate the WSDL's ? I guess that in php 5.3 the soap server expects the content length to be set in the header inorder to parse the complete wsdl, but the AutoDiscover class does not send this. By adding header('Content-Length: '.strlen($this->_wsdl->toXML())); to the handle function in the AutoDiscover class things are working I'll report the findings on the Zend bugtracker.For everybody that are looking for a little fix for that, force SoapClient to send an HTTP 1.0 request and your script may run again. It is working for me with PHP 5.3.0, ZEND 1.9 (minimal package, via PEAR) and APACHE 2.2.12 on Windows XP. <?php try { $context = stream_context_create( array( 'http' => array( 'protocol_version'=> '1.0' , 'header'=> 'Content-Type: text/xml;' , ), ) ); $options = array( 'stream_context' => $context , ); $client = new SoapClient( 'http://myserver/path?wsdl' , $options ); } catch( Exception $e ) { // You should not be here anymore } ?>I am using latest PHP 5.3 and still having this annoying bug - the easy quick fix for SoapServer error is to add header like (thank you "stig dot woxholt at fotoknudsen dot no" for indentifiying the problem). To fix this you have to add content-length in your wsdl generator code: header('Content-Length: '.strlen($strWsdl)); echo $restOfWsdl;