1

I am looking for help with this problem and I hope someone give me that help. The error is the following:

Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://example.com/index.php/api/?wsdl' : failed to load external entity "http://example.com/index.php/api/?wsdl" in /var/www/presentacion/app/code/local/Pengo/Extension/Model/Something.php on line 28

And the code that I'm using to connect to it is something like this:

$this->_soap = new SoapClient(http://example.com/index.php/api/?wsdl);

and there is where it says is the error.

I have been serching in Google, PHP forums, here in StackOverflow and Magento itself but I don't find the solution anywhere.

What I had seen is that the WSDL is never get parsed or loaded as the error says and none of its functions.

I tried connecting like this:

$options['location'] = http://example.com/index.php/api/?wsdl;
$options['uri'] = 'urn:Magento';
$this->_soap = new SoapClient(null, $options);

like this it doesn't dispatch any error like the others but there aren't functions to use, like in the other case it doesnt' load and parse the WSDL.

I am a bit frustrated because I have been developing this like 1 month and now that I am making some tests it shows this message, I had test it when it was really empty and new and it worked fine.

So any help would be appreciated.

Thank you.

apz2000
  • 132
  • 6
  • 14
  • Did you try loading the WSDL with the URL (http://example.com/index.php/api/?wsdl) in a browser? Is it a valid WSDL? You can use tools like `soapui` to check if the WSDL is valid and has all of it parts defined. – Ahamed Mustafa M May 24 '12 at 19:42
  • Yeah the WSDL is valid, that's what makes it weird – apz2000 May 24 '12 at 19:49
  • It would be great if you help me – apz2000 May 24 '12 at 20:10
  • The error tells you what is going wrong. If you need to debug the HTTP request, consider adding events and track what happens. You can use context options and callbacks for that, the SOAP client supports that. – hakre May 24 '12 at 20:14
  • @hakre like what? I am like new to this stuff of SOAP and webservices – apz2000 May 24 '12 at 22:20

3 Answers3

12

Nine times out of ten this error is Magento is telling you it can't load the WSDL file. Magento is telling you this. It's not your local client code that's complaining.

Magento uses the PHP SoapServer object to create its SOAP API. The SoapServer object needs to access the WSDL as well. Try running the following from your server's command line

curl http://example.com/index.php/api/?wsdl

If I'm right, the above will timeout/fail.

Because of some quirks in DNS, it's surprisingly common that a server won't be able to access itself via its domain name. If this is the case, the quickest fix is adding an entry to the server's hosts file. (Talk to your server admin if none of that made sense)

Alana Storm
  • 164,128
  • 91
  • 395
  • 599
  • Hi, thanks Alan, in this situation the tests are local, so I think there isn't the problem with the DNS, I am going to try the code in command line and tell you what happens. Thanks... UPDATE: I have tried the curl thing and it shows the WSDL perfectly, do you know what could be causing this? – apz2000 May 24 '12 at 22:14
  • Hi there @AlanStorm I was wondering if you came across some fix to this. Thanks – apz2000 May 25 '12 at 17:26
  • No, I wasn't looking for one. It's clear there's something wrong with your specific configuration that no remote person will be able to successfully debug. – Alana Storm May 25 '12 at 17:30
  • Ok, but you know where I can start looking or what can I do? @AlanStorm – apz2000 May 25 '12 at 17:53
  • Do you think that this is because it's all local and there isn't another machine @AlanStorm? – apz2000 May 25 '12 at 18:23
  • I'm not sure how to help you, maybe your company can spring for some training. – Alana Storm May 25 '12 at 19:41
  • Once again Alan made my day! I also used this [http://stackoverflow.com/a/924589/1398056](http://stackoverflow.com/a/924589/1398056) to get the precise trace of the soap call which can be useful. – baoutch Jul 11 '12 at 09:34
0

Well after all the things that I test the only one that worked for me, I don't know why but it worked, was doing this in two separate machines. I tried that because I read that somewhere and I just do it and my Magento and Webservice now works perfectly. Whenever I try to do this local it dispatch the same error.

I hope this can help someone in the future and they don't have to knock their head on the wall because of this problem.

Thank you all for your answers and comments.

apz2000
  • 132
  • 6
  • 14
0

Alan Storm is right on the Money here!

Make sure that you check your server Hosts File, and that it includes an entry for both domain and www.domain. Espicialy important if you are doing server rewrites.