0

Currently, I have my app servers deployed through Amazon Web Services Elastic Beanstalk. I have a separate EC2 instance set up as a backend admin server that is only accessible from our office. The admin server also shares the media folder with the app servers through NFS.

I have recently upgraded everything to CE 1.8.1 and installed the latest patches. I just noticed that the magento API stopped working - specifically v2_soap, although none of them seem to work. If I remember correctly, everything worked fairly well in 1.7. It probably even worked in 1.8. I am currently in the middle of testing the previous versions to make sure.

If I enter any of the following (as well as other variations) in a browser, I get a wsdl:

http://www.example.com/api/v2_soap?wsdl 
http://www.example.com/index.php/api/v2_soap?wsdl\
http://www.example.com/index.php/api/v2_soap/index/?wsdl

But in the wsdl, the <soap:address location> is

http://admin.example.com/index.php/api/V2_soap/index/ 

in all 3 cases.

Entering that url or the url with a ?wsdl at the end redirects me to the frontend www.example.com. Pretty much anything starting with admin.example.com/index.php redirects to the frontend(exception is index.php/admin).

Trying to post a soap request (login) to that admin soap address using Firefox SOA client returns

SOAP-ERROR: Parsing WSDL: Couldn't load from
'http://admin.example.com/index.php/api/v2_soap/index/?wsdl=1' :
failed to load external entity
"http://admin.example.com/index.php/api/v2_soap/index/?wsdl=1"

Similar results with my vb.net program that I wrote for syncing inventory.

I've also tried a bunch of other stuff. i tried posting soap to

http://www.example.com/index.php/api/v2_soap/index/

and other variations. No luck with anything.

The only way that I can get a wsdl through the admin server without getting redirected is to go to:

http://admin.example.com/api.php?type=v2_soap&wsdl=1

But that gives a <soap:address location> of

http://admin.example.com/index.php/?type=v2_soap

which is weird and useless. I tried a lot of other stuff, like changing the api server rewrites on the app and admin servers in .htaccess. NOthing seems to work.

Does anyone know if there were any changes in 1.81, the patches or 1.8 that might cause this odd behavior? Or did I change something else that resulted in this weird behavior?

Edit: I forgot an important fact. If I don't use the admin server (No to "Use Custom Admin URL"), the api works fine.

2 Answers 2

4

I had Auto-redirect to Base Url set to Yes for some reason. Setting it to No seems to have fixed it. I hope someone finds this useful.

The configuration can be viewed from System > Web > Url Options.

3
  • 1
    This setting is under the "Web" Section of the system configuration in the "URL Options" group.
    – beeplogic
    Sep 20, 2014 at 16:38
  • 2
    Given that "Auto-redirect to Base Url" is what will ensure that admin.example.com/frontend/blah is redirected to www.example.com, some might want this on. A better solution would be for Magento to fix this so that the custom admin path was not being used for domain in the WSDL. Nov 16, 2015 at 16:51
  • 1
    That did the trick fixing issue where api wsdl page was redirected to homepage when using custom admin url. Apr 7, 2017 at 2:19
0

Here the solution that worked for me, without updating the Magento configuration :

I set a rewrite rule on the web server (here Apache vhost) :

RewriteCond %{HTTP_HOST} ^admin\.magento\.biz$ [NC]
RewriteCond %{REQUEST_URI} /api/
RewriteRule ^ https://www.magento.biz%{REQUEST_URI} [L,R]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.