Magento API URL doesn't exist - php

I'm trying to setup a Magento API, but when I try to access the API URL I get a 404
For example, http://localhost/magento/api or http://localhost/magento/api/?wsdl go nowhere.
So when I try to connect to the server with the SoapClient I always get an error like this:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://localhost/magento/api/soap/?wsdl' : failed to load external entity "http://localhost/magento/api/soap/?wsdl" in /var/www/html/magento/soapclient.php:3 .
In fact, when I can't open the WSDL XML with the browser nor access the /api endpoint.
Do I have to do anything else before get ready to work with the SOAP API?

I think that you already solve your problem, but just to document. If you does not use CURL URL, you need to use the path to your WSDL using the
link: http://magentohost.com/index.php/api/soap/?wsdl

Related

Fatal error: Uncaught SoapFault exception: [WSDL] in php

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from "url" failed to load external entity.
I am getting below error when used SoapClient in the code. How to resolve this?
You should double check the URL to the SOAP service you require, and that it does indeed serve a wsdl (add ?wsdl to the end of the URL and inspect in a browser).
It sounds like your SOAP Service URL is missing a WSDL (service discovery) or is not finding a valid SOAP endpoint.
If you care to share your SOAP URL I can provide example or I/others might be able to help more.
Could also be character encoding or User Agent filtering on the SOAP endpoint, have a read of this question : SOAP-ERROR: Parsing WSDL: Couldn't load from - but works on WAMP

Alfresco wsdl access issue, SOAP failed

I have setup Alfresco on my local system.. I am trying to use AlfrescoPHPSDK-PHPLibrary-0.1 to get tickets. I am trying the examples provided in the package but it gives me following error.
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL
: Couldn't load from 'http://127.0.0.1:8080/alfresco/api/AuthenticationService?wsdl'
: failed to load external entity "http://127.0.0.1:8080/alfresco/api/AuthenticationService?wsdl" in D:\wamp\www\alfrescophp\Alfresco\Service\WebService\AlfrescoWebService.php:36
I have installed Alfresco on my local PC
I am able to open and login Alfresco from browser
http://127.0.0.1:8080/alfresco/api this URL accepted same credential.
But when I try to access http://127.0.0.1:8080/alfresco/api/AuthenticationService?wsdl It ask me username/Password and not accepting the credentials I used for Alfresco.
I was answered on alfresco forum that paths for SOAP API has been moved for alfresco 4.2.d.
Now instead of being http://localhost:8080/alfresco/api the soap services resides at http://localhost:8080/alfresco/soapapi.
Refrence: https://wiki.alfresco.com/wiki/Alfresco_Content_Management_Web_Services

How to implement PHP SoapClient using Soap Endpoint instead of using WSDL?

I have a requirement to write Soap Client in PHP to call a remote web service and get information. For that I got the Soap End Point URL which doesn't seems to be a WSDL.
I got the WSDL file in the IEPD document set for that Soap services.
When I tried to create new instance of the SoapClient using the End Point it is throwing below error.
"Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://...' : failed to load external entity "https://.." in..."
Can you please help me how should I find WSDL url using an endpoint? or is there any other way I can call the Soap using this end point without getting this error?
To add more reference, I have received the complete documentation of the SOAP webservice in a IEPD document.
Thanks
I suggest you have a look at PHP SoapClient documentation. Start with constructor function SoapClient::SoapClient. There are examples of non-WSDL usage

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from '' : failed to load external entity

This is the error I get:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing
WSDL: Couldn't load from
'http://subdomain.example.com:105/Example/Example.asmx?WSDL' : failed
to load external entity
"http://subdomain.example.com:105/Example/Example.asmx?WSDL"
as a result of this request:
$client = new SoapClient('http://subdomain.example.com:105/Example/Example.asmx?WSDL');
WHAT I TRIED:
Accessing this exact resource from my localhost or web browser also works.
Accessing other resources which don't have :105 works (if that could matter).
Tried to do socket_create_listen(105) but gotten "Permission denied" error. Then tried to enable Port 105 via WHM by adding it firewall to the list of ports (IPv4, IPv4, TCP and UDP). All that still didn't work and there was no response from port 105.
allow_url_fopen is switched On.
default_socket_timeout is set to 300.
Tried this answer: https://stackoverflow.com/a/7118802 (parameters that I changed are URL and port - which I changed to 105. Other parameters I've left literally identical, maybe that was a mistake?)
As per some other SO answers, tried using https instead, doesn't work. Tried adding www. but that URL doesn't even exist.
Tried echoing file_get_contents() as per this answer: https://stackoverflow.com/a/14729295/525445 - it gives me a blank screen.
Tried this: Fatal error: Uncaught SoapFault exception: [WSDL] which has resulted in
Fatal error: Uncaught SoapFault exception: [HTTP] Could not connect to
host
Tried fetching it with cURL, as suggested here: https://stackoverflow.com/a/5311925/525445 The response I got is bool(false)
I had the exactly same problem today. In my case, the reason lied some steps higher. It's a magento installation and it didn't work, because i didn't whitelist api calls (even though I whitelisted my IP, what strangely wasn't enough). For me, the fix:
if (file_exists($maintenanceFile) && !in_array($ip, $allowed) && !strstr($_SERVER['REQUEST_URI'], 'v2_soap')) {
include_once dirname(__FILE__) . '/errors/503.php';
exit;
}
did it.
Should you NOT use magento, this could be nonetheless interesting for you, as it shows, that the reason can lay on a index or a htaccess file, layers above the wdsl itself. With the browser i could access the address, just like you. So maybe there's a controll switch in your system, that kills the request.

Unable to connect to Magento SOAP API v2 due to “failed to load external entity” after giving IP restriction in .htaccess file

I am unable to connect to the Magento SOAP API v2 using PHP. The error that occurs is:
PHP Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.mydomain.com/index.php/api/v2_soap/index/wsdl/1/' : failed to load external entity "http://www.mydomain.com/index.php/api/v2_soap/index/wsdl/1/"
I gave IP restriction in .htaccess file such that only I will be able to view the site while development.
When I remove the IP restriction from the .htaccess file it works fine.
Any help would would be great as it's mandatory keep IP restriction!
You probably need to add the server's ip address to the whitelist as well.

Categories