当我尝试连接magento v2.0.2 SOAP API时出现此错误。
我在localhost上运行
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
我尝试了大多数解决方案,但没有一个解决方案。
答案 0 :(得分:0)
这对我有所帮助:
$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);