duangu9666 2018-07-22 14:18
浏览 70

使用自签名证书连接到dev magento soap api v1 - 错误的版本错误

I need to connect to Magento SOAP API v1 dev server, which is running over https using self-signed ssl certificate.

Given my soap api url is: https://my-store.com/index.php/api/soap/?wsdl

The traditional way of initiating a soap client like this:

$client = new SoapClient($soap_api_url);

This produces the following error:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://my-store.com/index.php/api/soap/?wsdl'

I figured the error must be due to self-signed certificate, so I tried a different approach like this:

$context = stream_context_create([
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
        'allow_self_signed' => true
    ]
]);

$client = new SoapClient(null, [
    'location' => $soap_api_url,
    'uri' => 'urn:Magento',
    'stream_context' => $context
]);

This no longer complains about not being able to load the WSDL, now returns this error:

Wrong Version

I think the problem is with the uri in the connection option; any idea how to tell this code I want to connect to v1 of the magento soap api?

  • 写回答

1条回答 默认 最新

  • dongliao3742 2018-07-22 21:12
    关注

    I've fixed it like this:

    $context = stream_context_create([
        'ssl' => [
            'verify_peer' => false,
            'verify_peer_name' => false,
            'allow_self_signed' => true
        ]
    ]);
    
    $client = new SoapClient($soap_api_url, [
        'stream_context' => $context
    ]);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法