I am trying to create a soap client by passing a url that is hosted on my local machine, my dev environment and I keep getting this error. I use to be able to make this call and it worked just fine.
Basically all I am doing is this
$client = new SoapClient('http://virtual.website.com:81/api/?wsdl');
If I go to the url in a browser it comes up, so I know it is the right location. On the Magento forums there are some similar posts but I don't know that this is a Magento specific problem. Everything they mention as a solution I already have. They say to edit the hosts file for example 127.0.0.1 website.com
I already have this since it is setup as a virtual host.
Here is the error in my error_log
[Fri Jun 04 12:30:37 2010] [error] [client 127.0.0.1] PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://virtual.website.com:81/api/soap/?wsdl' : XML declaration allowed only at the start of the document\n in /usr/local/sites/virtual.website.com/www/CUSTOMSCRIPTS/removeProductImages.php on line 6
[Fri Jun 04 12:30:37 2010] [error] [client 127.0.0.1] PHP Stack trace:
[Fri Jun 04 12:30:37 2010] [error] [client 127.0.0.1] PHP 1. {main}() /usr/local/sites/virtual.website.com/www/CUSTOMSCRIPTS/removeProductImages.php:0
[Fri Jun 04 12:30:37 2010] [error] [client 127.0.0.1] PHP 2. SoapClient->SoapClient(*uninitialized*) /usr/local/sites/virtual.website.com/www/CUSTOMSCRIPTS/removeProductImages.php:6
UPDATE:: I have found that this isn't an issue with SOAP something is adding extra spaces to my XML file.
I had exactly the same problem. I had installed Zend Server (PHP 5.3.9) and was getting the same error. I searched a lot and applied all available solutions but all failed. Finally, I installed wamp and then run 'Soap Client' script over there and it runs successfully.
Then I reached on this point that Zend Server (PHP 5.3.9) has some default bug in 'Soap Client' Script. I uninstalled Zend Server (PHP 5.3.9) and installed Zend Server (PHP 5.4.11) and runs 'Soap Client' script over there. This time it runs successfully.
Conclusion: Please use latest PHP version (Zend Server) or (Wamp Server) as, there is default 'Soap Client' bug in some PHP versions, one I mentioned above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With