SOAP – Unable to Connect to Soap Server

soap

im trying to connect to the magento soap server.

I have set up the soap role and user that i want to use, and then i wrote a script called soap.php and placed it in my website public_html for testing, which looks like this:

<?php
// Magento login information
require_once('app/Mage.php');
Mage::app();

$mage_url = 'https://mrandmrsgrey.com/api/v2_soap?wsdl';
$mage_user = 'soaper';
$mage_api_key = '24648625';
// Initialize the SOAP client
$soap = new SoapClient( $mage_url );
// Login to Magento
$session_id = $soap->login( $mage_user, $mage_api_key );

But for some reason when i run the script i get this error:

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find in 'https://mrandmrsgrey.com/api/v2_soap?wsdl'

Ive crawled the net but any solutions that popped up havent worked i.e. turning off "Add Store Code to URLs"

Im running magento CE 1.7. Any help will be much appreciated

Best Answer

In a SOAP web service, a WSDL file is the file that describes all the methods available in the service. This information is structured in such a way that the SoapClient will know the XML is needs to send to make the method calls.

The cryptic error message

Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find in 'https://mrandmrsgrey.com/api/v2_soap?wsdl'

Is PHP telling you is had a problem with your the WSDL file. If I load your WSDL file in a browser

https://mrandmrsgrey.com/api/v2_soap?wsdl

There's no XML WSDL available.

enter image description here

It appears someone has set your site to maintenance mode. Further, it appears that maintenance mode disables the API as well as the site.

Turn off maintenance mode (remove the maintaince.flag file in your document root) and you'll likely be able to access the API.

Related Topic