I am getting some soap fault error with the message as below :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>WSDL</faultcode><faultstring>SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://magento/index.php/api/index/index/?wsdl=1' : Start tag expected, '<' not found
</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
FYI : It was working few days before. We created one of the store recently and we also removed each and every file regarding new store including etc/modules, newly installed extensions and layout files.
When we try to access url from SSH using wget command
shop@magento:~/htdocs$ wget www.magento.com/api/index
--2014-04-04 08:59:37-- http://www.magento.com/api/index
Resolving www.magento.com... 12.345.678.901
Connecting to www.magento.com|12.345.678.901|:80... connected.
HTTP request sent, awaiting response... 500 Internal Service Error
2014-04-04 08:59:48 ERROR 500: Internal Service Error.
If I try to access http://www.magento.com/api.php?type=soap&wsdl=1
I am getting following output.
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
name="Magento" targetNamespace="urn:Magento">
<types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
<!-- <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />-->
<complexType name="FixedArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:anyType[]" />
</restriction>
</complexContent>
</complexType>
</schema>
</types>
<message name="call">
<part name="sessionId" type="xsd:string" />
<part name="resourcePath" type="xsd:string" />
<part name="args" type="xsd:anyType" />
</message>
<message name="callResponse">
<part name="callReturn" type="xsd:anyType" />
</message>
<message name="multiCall">
<part name="sessionId" type="xsd:string" />
<part name="calls" type="typens:FixedArray" />
<part name="options" type="xsd:anyType" />
</message>
<message name="multiCallResponse">
<part name="multiCallReturn" type="typens:FixedArray" />
</message>
<message name="endSession">
<part name="sessionId" type="xsd:string" />
</message>
<message name="endSessionResponse">
<part name="endSessionReturn" type="xsd:boolean" />
</message>
<message name="login">
<part name="username" type="xsd:string" />
<part name="apiKey" type="xsd:string" />
</message>
<message name="loginResponse">
<part name="loginReturn" type="xsd:string" />
</message>
<message name="resources">
<part name="sessionId" type="xsd:string" />
</message>
<message name="resourcesResponse">
<part name="resourcesReturn" type="typens:FixedArray" />
</message>
<message name="globalFaults">
<part name="sessionId" type="xsd:string" />
</message>
<message name="globalFaultsResponse">
<part name="globalFaultsReturn" type="typens:FixedArray" />
</message>
<message name="resourceFaults">
<part name="resourceName" type="xsd:string" />
<part name="sessionId" type="xsd:string" />
</message>
<message name="resourceFaultsResponse">
<part name="resourceFaultsReturn" type="typens:FixedArray" />
</message>
<message name="startSession" />
<message name="startSessionResponse">
<part name="startSessionReturn" type="xsd:string" />
</message>
<portType name="Mage_Api_Model_Server_HandlerPortType">
<operation name="call">
<documentation>Call api functionality</documentation>
<input message="typens:call" />
<output message="typens:callResponse" />
</operation>
<operation name="multiCall">
<documentation>Multiple calls of resource functionality</documentation>
<input message="typens:multiCall" />
<output message="typens:multiCallResponse" />
</operation>
<operation name="endSession">
<documentation>End web service session</documentation>
<input message="typens:endSession" />
<output message="typens:endSessionResponse" />
</operation>
<operation name="login">
<documentation>Login user and retrive session id</documentation>
<input message="typens:login" />
<output message="typens:loginResponse" />
</operation>
<operation name="startSession">
<documentation>Start web service session</documentation>
<input message="typens:startSession" />
<output message="typens:startSessionResponse" />
</operation>
<operation name="resources">
<documentation>List of available resources</documentation>
<input message="typens:resources" />
<output message="typens:resourcesResponse" />
</operation>
<operation name="globalFaults">
<documentation>List of resource faults</documentation>
<input message="typens:globalFaults" />
<output message="typens:globalFaultsResponse" />
</operation>
<operation name="resourceFaults">
<documentation>List of global faults</documentation>
<input message="typens:resourceFaults" />
<output message="typens:resourceFaultsResponse" />
</operation>
</portType>
<binding name="Mage_Api_Model_Server_HandlerBinding" type="typens:Mage_Api_Model_Server_HandlerPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
<operation name="call">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="multiCall">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="endSession">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="login">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="startSession">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="resources">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="globalFaults">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
<operation name="resourceFaults">
<soap:operation soapAction="urn:Mage_Api_Model_Server_HandlerAction" />
<input>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</input>
<output>
<soap:body namespace="urn:Magento" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</output>
</operation>
</binding>
<service name="MagentoService">
<port name="Mage_Api_Model_Server_HandlerPort" binding="typens:Mage_Api_Model_Server_HandlerBinding">
<soap:address location="http://www.magento.com/index.php/?type=soap" />
</port>
</service>
</definitions>
My current magento version is 1.7.0.2, required PHP extensions are loaded. Please help me, I am getting stuck since last two days.
Edit :
One of the important thing, when we remove theme switcher code base on server host, we are getting following soap fault code by running http://www.magento.com/api/index :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Here is the switcher code we placed into root index
switch($_SERVER['HTTP_HOST']) {
case 'test1.magento1.com':
define('STORECODE1', 'storecode1_storeview');
Mage::run(STORECODE1,$mageRunType);
break;
case 'www.magento.com':
define('MOBILESTORECODE', 'mobilemagento');
if (isMobile()) {
$mobile = Mage::app()->getRequest()->getParam('mobile');
if(isset($mobile) && $mobile == 'no') {
Mage::run($mageRunCode, $mageRunType);
}else{
Mage::run($mageRunCode, $mageRunType);
//Mage::run(MOBILESTORECODE,$mageRunType);
}
} else {
Mage::run($mageRunCode, $mageRunType);
}
break;
default:
Mage::run($mageRunCode, $mageRunType);
break;
}
Also, using this url with the store switcher code removed, we are getting – http://www.magento.com/api.php?type=soap
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>WSDL</faultcode><faultstring>SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.magento.com/index.php/?type=soap&wsdl=1' : Extra content at the end of the document
Best Answer
Found out the solution after 3 days juggling. Thanks to https://stackoverflow.com/questions/12538343/magento-api-soap-error-parsing-wsdl-couldnt-load-from-url-index-php-api-in I had not noticed yet the correct response(Literally my mistake).
I was getting following warning from index that I ignored
I turned off
and now, API's got working and looking to solve warnings.. So, issue - system is expecting start tag of xml reponse as '<' while it was being given xml with warning message, though warnings were not being displayed in xml response.