gpt4 book ai didi

php - 使用 PHP SoapClient 访问 Magento API 导致重定向 - 通过浏览器访问有效

转载 作者:搜寻专家 更新时间:2023-10-31 21:11:41 25 4
gpt4 key购买 nike

我正在使用 PHP 的 SoapClient 访问 Magento SOAP API v2

$soap_client = new SoapClient($wsdl_url, array('trace' => 1));

wsdl url 是 http://www.example.org/index.php/api/v2_soap/?wsdl=1
在浏览器中打开 url 会生成有效的 xml 文档。
但是 当我使用 SoapClient 访问相同的 url 时,我从 $soap_client->__getLastResponse() 收到以下错误消息:

Invalid webservice adapter specified.

使用 $soap_client->__getLastRequestHeaders() 查看请求 header 显示调用被重定向到 http://www.example.org/api/v2_soap/index/:

POST /api/v2_soap/index/ HTTP/1.1
Host: www.example.org
Connection: Keep-Alive
User-Agent: PHP-SOAP/5.4.3
Content-Type: text/xml; charset=utf-8
SOAPAction: "urn:Mage_Api_Model_Server_V2_HandlerAction"
Content-Length: 542

在浏览器中调用该 url (http://www.example.org/api/v2_soap/index/) 会输出与 SoapClient 返回相同的错误消息(无效的网络服务适配器指定。)

SoapClient 怎么可能在正常的 http 请求工作正常的情况下被重定向?

非常感谢任何帮助

最佳答案

The effect of MultiViews is as follows: if the server receives a request for /some/dir/foo, if /some/dir has MultiViews enabled, and /some/dir/foo does not exist, then the server reads the directory looking for files named foo.*, and effectively fakes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements.

关于php - 使用 PHP SoapClient 访问 Magento API 导致重定向 - 通过浏览器访问有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18274806/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com