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?
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
]);