代码之家  ›  专栏  ›  技术社区  ›  Veerakran Sereerungruangkul

始终重定向Magento SOAP API请求[Magento 1.9.3.3]

  •  2
  • Veerakran Sereerungruangkul  · 技术社区  · 6 年前

    我正在开发C#应用程序以与Magento通信。当我尝试登录以获取会话ID来执行任务时。我在下面使用C代码。

    我的登录代码

    using (MagentoService mservice = new MagentoService())
        {    
            loginResponse = mservice.login("admin", "admin123");
        }
    

    它总是让我犯这个错误

    System.ServiceModel.FaultException: 'SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://admin.mywebsite.com/index.php/api/v2_soap/index/?wsdl=1' : Premature end of data in tag html line 7
    

    因为我的API请求每次都会被重定向到网站的主页。

    有关此错误的详细信息,请访问此链接: Cannot login Magento service using C# [Magento 1.9.3.3] Error: Premature end of data in tag html line 7 )

    有没有办法阻止我的API请求被重定向?是否可以在不干扰Magento设置的情况下从客户端执行?

    2 回复  |  直到 6 年前
        1
  •  1
  •   Veerakran Sereerungruangkul    6 年前

    我要求服务器所有者禁用来自API请求端点URL的重定向( https://admin.mywebsite.com/index.php/api/v2_soap/index/ )一切正常

        2
  •  0
  •   DependencyHell    5 年前

    在Magento服务器端,我必须在Apache vhost配置中设置以下内容:

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

    这似乎是一个已知的Magento bug,有两个参数发生冲突:

    • 自动重定向到基本Url
    • 对子域使用自定义管理员URL