title: Magento Soap API working locally but not remotely
body: <p>I have created a custom API for Magento Enterprise 1.11. Calling the API through Soap v1 works fine on my local dev environment, however I am unable to make calls from my local environment to the remote environment.</p>
  
  <p>Using PHP interactive shell on my localdev:</p>
  
  <pre><code>php &gt; $client = new SoapClient(WSDL_URI,array('trace'=&gt;1));
  php &gt; $client-&gt;login(API_USER,API_KEY);
  php &gt; var_dump($client-&gt;__getLastResponse());
  string(538) "&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;&lt;SOAP-ENV:Body&gt;&lt;ns1:loginResponse&gt;&lt;loginReturn xsi:type="xsd:string"&gt;f0eec73e49665aaf9cc4a6644fba5dc6&lt;/loginReturn&gt;&lt;/ns1:loginResponse&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>I have been able to do this successfully from the localhost, as well as between two local VMs running on my dev machine. I can also access the methods of my custom API without issue.</p>
  
  <p>However, when I try to make a soap client to my remote test environment, I am able to create the client, but the call to $client->login(), or any subsequent call results in the following:</p>
  
  <pre><code>php &gt; $client = new SoapClient(REMOTE_WSDL_URI,array('trace'=&gt;1));
  php &gt; $client-&gt;login(API_USER,API_KEY);
  PHP Warning:  Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://REMOTE_HOST/index.php/api/index/index/wsdl/1/' : failed to load external entity "http://REMOTE_HOST/index.php/api/index/index/wsdl/1/" in php shell code:1
  Stack trace:
  #0 php shell code(1): SoapClient-&gt;__call('login', Array)
  #1 php shell code(1): SoapClient-&gt;login(API_USER, API_KEY)
  #2 {main}
  php &gt; var_dump($client-&gt;__getLastRequestHeaders());
  string(255) "POST /index.php/api/index/index/ HTTP/1.1
  Host: REMOTE_HOST
  Connection: Keep-Alive
  User-Agent: PHP-SOAP/5.3.18-1~dotdeb.0
  Content-Type: text/xml; charset=utf-8
  SOAPAction: "urn:Mage_Api_Model_Server_HandlerAction"
  Content-Length: 550
  
  php &gt; var_dump($client-&gt;__getLastResponseHeaders());
  string(840) "HTTP/1.1 500 Internal Service Error
  Date: Mon, 11 Feb 2013 19:06:56 GMT
  Server: Apache/2.2.16 (Debian)
  X-Powered-By: PHP/5.3.19-1~dotdeb.0
  Set-Cookie: PHPSESSID=7uqrcmiv96hroubnb1uu7c7cm6; expires=Wed, 13-Feb-2013 01:06:56 GMT; path=/; domain=.REMOTE_HOST; HttpOnly
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
  Pragma: no-cache
  Set-Cookie: CUSTOMER=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.REMOTE_HOST; httponly
  Set-Cookie: CUSTOMER_INFO=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.REMOTE_HOST; httponly
  Set-Cookie: CUSTOMER_AUTH=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.REMOTE_HOST; httponly
  Content-Length: 468
  Vary: Accept-Encoding
  Connection: close
  Content-Type: text/xml; charset=utf-8
  
  php &gt; var_dump($client-&gt;__getLastResponse());
  string(468) "&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;SOAP-ENV:Body&gt;&lt;SOAP-ENV:Fault&gt;&lt;faultcode&gt;WSDL&lt;/faultcode&gt;&lt;faultstring&gt;SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://REMOTE_HOST/index.php/api/index/index/wsdl/1/' : failed to load external entity "http://REMOTE_HOST/index.php/api/index/index/wsdl/1/"
  &lt;/faultstring&gt;&lt;/SOAP-ENV:Fault&gt;&lt;/SOAP-ENV:Body&gt;&lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>When I hit //REMOTE_HOST/index.php/api/?wsdl I get the standard Magento WSDL.</p>
  
  <p>The two environments are 99.99% identical:</p>
  
  <ul>
  <li>Server version: Apache/2.2.16 (Debian) (both local dev and remote)</li>
  <li>PHP 5.3.18 (local dev) 5.3.19 (remote host) </li>
  <li>Apache/PHP configurations are the same.</li>
  <li>Code base is identical</li>
  </ul>
  
  <p>I have scoured the intewebs for clues, including:</p>
  
  <ul>
  <li><a href="http://www.magentocommerce.com/boards/viewthread/56528/" rel="nofollow noreferrer">http://www.magentocommerce.com/boards/viewthread/56528/</a></li>
  <li><a href="http://www.magentocommerce.com/wiki/5_-_modules_and_development/web_services/overriding_an_existing_api_class_with_additional_functionality#wsdl" rel="nofollow noreferrer">http://www.magentocommerce.com/wiki/5_-_modules_and_development/web_services/overriding_an_existing_api_class_with_additional_functionality#wsdl</a></li>
  <li><a href="https://stackoverflow.com/questions/6454644/unable-to-connect-to-magento-soap-api-v2-due-to-failed-to-load-external-entity">Unable to connect to Magento SOAP API v2 due to &quot;failed to load external entity&quot;</a></li>
  <li><a href="https://stackoverflow.com/questions/12538343/magento-api-soap-error-parsing-wsdl-couldnt-load-from-url-index-php-api-in">Magento API SOAP-ERROR: Parsing WSDL: Couldn&#39;t load from &#39;[url]/index.php/api/index/index/?wsdl=1&#39; : Couldn&#39;t find end of Start Tag part line 56</a></li>
  <li><a href="http://www.magentocommerce.com/api/soap/introduction.html" rel="nofollow noreferrer">http://www.magentocommerce.com/api/soap/introduction.html</a></li>
  </ul>
  
  <p>I've tried the "Content-Length" header fix mentioned in the sedond-to-last link, and just about everything else I could think of... Stumped.</p>