Search code examples
phpxmlmagentosoapmagento-soap-api

Magento API Error: XML declaration allowed only at the start


I'm trying to access Magento's core API. When I try to access the url http://magentohost/index.php/api/soap/wsdl=1 I get the error

This page contains the following errors:

error on line 1 at column 6: XML declaration allowed only at the start of the document

Below is a rendering of the page up to the first error.

I have installed xmlrpc, soap, and other extensions that is said to be required but still no luck.

Other magento instances in my host shows

This XML file does not appear to have any style information associated with it. The document tree is shown below.

plus a block of XML codes below it.

It's said that I may have white spaces on my XML document but I have no idea what XML document I should modify.


Solution

  • You probably have whitespace in some php/phtml file/s before the starting <?php or at the end of the file, after the closing ?>.

    An xml with a precedeing whitespace is invalid and will give an error like yours.

    Check the following links for further explanation:

    https://magento.stackexchange.com/questions/92139/space-added-before-every-magento-page-content

    Find whitespace-injecting PHP files