Magento SOAP V1 – Change SOAP Address in Magento Enterprise

magento-enterprisemultistoresoap

We have a multistore magento setup thats still half in development. But we have 1 of the stores open with a test url.

e.g test.domain.com

However when we go to: http://test.domain.com/index.php/api/index/?wsdl=1
I noticed that soap:address shows the main domain not the api url e.g:

<soap:address location="https://www.domain.com/index.php/api/index/index/?SID=vnl0ijdobf6ldj76pmc658rj92"/>

Which atm isn't live.
We have no issues with 3rd parties who come in on the V2 api but this doesn't seem to have a soap:address which I believe is the problem.

When I go to: http://test.domain.com/index.php/api/index/?wsdl=1 in a browser it shows xml.
When I try and make a soap call i get: looks like we got no XML document.

When I update my local hosts file with the new ip to point at the domain it will work.
But the 3rd party can't update their server because its shared hosting. Is there a way to change the API to point at the api url and not the base store url?

Best Answer

Try and set the store url in admin as {{base_url}} (this must be changed before you go live). Using that magento will use whatever domain as used to call the site.

Update, after OP comments:

If you trace the code on how the WSDL gets built, you will find the wsdl.xml file in app/code/core/Mage/Api/etc/wsdl.xml

at the end of that file:

<service name="{{var wsdl.name}}Service">
        <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
            <soap:address location="{{var wsdl.url}}" />
        </port>
    </service>

thus magento populates the url in the file from a var called wsdl.url.

Searching the code for where that gets populated reveals:

Mage_Api_Model_Server_Adapter_Soap::run

$wsdlConfig->setUrl(
                htmlspecialchars(Mage::getUrl('*/*/*', array('_query'=>$queryParams) ))
            );

Thus the url is generated using standard magento getUrl method, thus reading it from your config.

So it is very likely that you changed the wrong one. Did you change the default base url, or the site base url? Try the other, or both.

Alternatively, you can copy the wsdl.xml to your local folder, and temporarily override it and hard-code the address. This is a really bad hack, and should try not to do it, but should help you get your testing done ;) It is most likely that you'd need to do this elsewhere, so I would do that as a last resort only.

Related Topic