当我尝试连接 magento v2.0.2 SOAP API 时,出现此错误。
我在本地主机上运行
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://127.0.0.1/cms_framework/Magento-CE-2.0.2/soap?wsdl' :
failed to load external entity "http://127.0.0.1/cms_framework/Magento-CE-2.0.2/soap?wsdl" in /var/www/html/upwork/ci_api_work/api/application/libraries/magentoapi.php:37 Stack trace:
#0 /var/www/html/upwork/ci_api_work/api/application/libraries/magentoapi.php(37): SoapClient->SoapClient('http://127.0.0....')
#1 /var/www/html/upwork/ci_api_work/api/system/core/Loader.php(1011): magentoapi->__construct()
#2 /var/www/html/upwork/ci_api_work/api/system/core/Loader.php(888): CI_Loader->_ci_init_class('magentoapi', '', NULL, NULL)
#3 /var/www/html/upwork/ci_api_work/api/system/core/Loader.php(138): CI_Loader->_ci_load_class('magentoapi', NULL, NULL)
#4 /var/www/html/upwork/ci_api_work/api/application/controllers/magento.php(11): CI_Loader->library('magentoapi')
#5 /var/www/html/upwork/ci_api_work/api/application/controllers/magento.php(23): magento->connect()
#6 [internal in /var/www/html/upwork/ci_api_work/api/application/libraries/magentoapi.php on line 37
我尝试了大部分解决方案,但没有一个有效。
这对我有帮助:
$opts = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$options = array (
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
'stream_context' => stream_context_create($opts),
'cache_wsdl' => WSDL_CACHE_NONE,
//'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 1
);
$client = new SoapClient($yourServer, $options);