5

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.

7
  • The error message is not very detailed... could you put your code snippet in a try/catch structure, where you would var_dump the thrown Exception, just to see if there are more details? I don't know if all the fields in this constructor fr2.php.net/manual/en/soapfault.soapfault.php are visible in the error message you get. Commented Jun 5, 2010 at 10:54
  • 1
    I tried that but it doesn't seem to catch it. I found that weird. Another thing. I had my co-worker try it out on the same project on their local machine and it worked. It makes me think there is something weird going on in my local machine. Commented Jun 5, 2010 at 13:36
  • It isn't caught because it is a Fatal error. Which is a bug : look here bugs.php.net/bug.php?id=34657 But there is something interesting in your error message : 'XML declaration allowed only at the start of the document' I think there must be something unintended before it, try to get your page with wget and look at your code with vi, to see if there are extra characters before this XML declaration. Commented Jun 5, 2010 at 13:52
  • hmm there are spaces when doing that, but this file should be the same as any other file that the other co-worker has and it worked for them Commented Jun 6, 2010 at 1:01
  • Another thing, the actual xml file that is in the code, the xml declaration is on line 1, what might add space there. Commented Jun 6, 2010 at 1:08

5 Answers 5

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

After changing URL settings of Magento or your local environment you should always clear Magento /var/cache/ directory. Usually all weird errors disappear with it.

Comments

0

The answer seemed to be for us that we had not enabled the xmlrpc PHP extension. Once we did that the error went away.

Comments

0

Also the problem could be related to rights on soap.wsdl_cache_dir directory

1 Comment

This is really a comment, not an answer. With a bit more rep, you will be able to post comments.
0

I solved this on my WAMP setup by enabling the php_openssl extension, since the URL I was loading from used https://.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.