Soap error when trying to use the API of Magento - php

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.

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)

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.

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.

Related

Issue with the implementation of the simplesamlphp library into my web application

I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.

how to configure facebook api in localhost in xampp or wamp server? what is php.ini settings requirement to use it?

I m new to use of facebook api after some googling i found facebook api from this link:
https://github.com/facebook/facebook-php-sdk
after download this package i try to execute example code from this package but it returns an error like:
Fatal error: Uncaught CurlException: 6: Could not resolve host: graph.facebook.com; Host not found thrown in D:\xampp\htdocs\testing\phpdemo\fb\src\base_facebook.php on line 994
to solve this problem i try too much googling but i doesnt get positive result from there.
If anybody know what kind of possibilities for this problem then please help.
here is may be two posibilities like:
1) Do you have any firewalls? The problem is not about configuration is just CURL can't do requests to graph.facebook.com and possible any website. Try disable any firewalls that may be blocking your CURL requests
2) From my experience you can't use facebook APi local, however they have a free host provider,Heroku, try it. Also don't forget to replace YOUR_APP_ID and YOUR_APP_SECRET with your app Data.
You can get help here,https://stackoverflow.com/questions/16294630
From my experience you can't use facebook APi local, however they have a free host provider,Heroku, try it.
Also don't forget to replace YOUR_APP_ID and YOUR_APP_SECRET with your app Data.

OpenX: Moved to different Server

I moved the installation to a different server. I updated the configfile in the var/ directory and the banners are served, but the admin interface is not working.
i get the error:
A fatal error occurred OpenX can't connect to the database. Because of
this it isn't possible to use the administrator interface
i cleaned the cache directory in var but then i get
PHP Fatal error: Call to undefined method MDB2_Error::quoteIdentifier() in /[path]/opx/lib/OA/Upgrade/VersionController.php on line 50
I dont know which version this is, but it looks like its at least 2 years old.
Is there any special cache in place im not aware of?
Any help on this would be much appreciated.
Mental note,.. if you have the db on a different server then openx it does not matter if you set the host to the ip of the db server and the port.. as long if you not set protocol=protocol !!!
this is by far the most stupidest thing i have ever seen, there is no need for a protocol config, as php always uses the socket if you set "localhost".
It's not easy to tell exactly what's wrong here, but one can make a good guess:
As we can see from the error message, there is an object in your code that doesn't implement the method quoteIdentifier().
There are mainly two possible reasons for this: Either we're calling an older or newer version of the same Class instance which doesn't implement the method. Maybe because it's deprecated or who knows. Or the object simply isn't of the expected type.
Lo and behold, if we look for an MDB2 related class that DOES implement this method, it's the class MDB2. Not MDB2_Error! So now we know the reason for the error, it's time to speculate about the root cause.
Connecting to a database with MDB2 works roughly like this:
$mdb2 =& MDB2::connect('pgsql://usr:pw#localhost/dbnam');
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
There it is. We can see that $mdb2 can actually be of type MDB2_Error, in case connecting goes wrong for some reason. So that is the cause: Your code cannot connect to the DB for some reason. So the next obvious step should be checking if your db user has the correct rights and is using the correct password. I am 100% sure your admin backend doesn't use the right credentials.

Php and tomcat configuration

I have to edit some project in php to my work. I also admit that I'm completly noob in php. I try to configure php and tomcat 6.0 but without success. I making everything like in this tutorial:
http://blog.jackneer.com/2008/10/php-5-on-tomcat-6-installation.html
But I got an error:
type Exception report
message Wrapper cannot find servlet class net.php.servlet or a class
it depends on
description The server encountered an internal error that prevented it
from fulfilling this request.
exception javax.servlet.ServletException: Wrapper cannot find servlet
class net.php.servlet or a class it depends on
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703)
java.lang.Thread.run(Thread.java:722)
root cause java.lang.ClassNotFoundException: net.php.servlet
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600)
org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703)
java.lang.Thread.run(Thread.java:722)
note The full stack trace of the root cause is available in the Apache
Tomcat/6.0.36 logs.
I was searching on google but I don't found anything helpful. Do you know what should I do? I want to do it on tomcat but if I have to, I used different server. But which is the best to working with php? And easy to configure of course :) Thanks in advance for your help.

Zend_Soap - Error parsing WSDL: Start tag expected, '<' not found

For the same WSDL, which is totally valid, I am able to access it properly using PEAR SOAP like this:
$WSDL = new SOAP_WSDL($this->wsdlUrl);
$proxy = $WSDL->getProxy();
But not able to make it work through Zend_Soap, when used like this:
$soapclient = new Zend_Soap_Client($this->wsdlUrl);
I get the following error when accessed through Zend_Soap_Client:
Error: SOAP-ERROR: Parsing WSDL: Couldn't load
from 'https://abc.xyz.com/agent/TestService.php?wsdl' : Start tag expected, '<' not found
Openssl is also enabled in my php.ini
Does anybody know why it doesn't work? and how I can fix it to use Zend_Soap properly?
You should check if the ssl-Certificate is valid. This Error Message is also thrown if ssl-certificate verification fails.
Check to make sure that no Ports are blocked in your hosting situation.
I've had the same error, though with different code just plain php, and was struggling with it for several days.
It turned out that my webhotel had blocked the port I needed to access the web service.
Or it could some proxy-related issue giving the same blocked result.
Are you using HTTP Authentication? Auth works with SOAP Client, however you cannot access password protected WSDL files
See https://bugs.php.net/bug.php?id=27777

Categories