I'm trying to get all products in $productArrarray from magento 2 API via SOAP client. I tried the below function but it throws this error:


SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://shop.mysite.com/soap/default?wsdl&services=catalogProductRepositoryV1' : failed to load external entity "https://shop.mysite.com/soap/default?wsdl&services=catalogProductRepositoryV1"


public function getMagentoProducts() {

    $productArr = array('' => 'Select Product');

    try {
        $request = new SoapClient("https://shop.mysite.com/soap/?wsdl&services=integrationAdminTokenServiceV1", array("soap_version" => SOAP_1_2));
        $token = $request->integrationAdminTokenServiceV1CreateAdminAccessToken(array("username"=>"user", "password"=>"pass"));
        $opts = array(
                'header' => 'Authorization: Bearer '.json_decode($token->result),
                'user_agent' => 'PHPSoapClient'
            'ssl' => array(
                'verify_peer' => false,
                'verify_peer_name' => false,
                'allow_self_signed' => true
        $wsdlUrl = 'https://shop.mysite.com/soap/default?wsdl&services=catalogProductRepositoryV1';

        $context = stream_context_create($opts);
        $soapClientOptions = array(
            'stream_context' => $context,
            'cache_wsdl' => WSDL_CACHE_NONE

        $soapClient = new SoapClient($wsdlUrl, ['version' => SOAP_1_2, 'context' => $soapClientOptions]);
        $soapResponse = $soapClient->__getFunctions();

    } catch (Exception $e) {


2 Answers 2


If you are using a development site with an SSL that is not signed by a major CA, then when PHP goes to load external entities from your domain, your SSL certificate can cause this error.

I just had to add my root CA certificate that signed my SSL to the trusted roots of my server and the error went away.

For Ubuntu 16.04 I added the PEM version of my root CA to /usr/local/share/ca-certificates then ran sudo update-ca-certificates and it was added.


I made this error go away by enabling the php module openssl (Windows server)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.