Ошибка parsing wsdl couldn t load from

This works fine on my WAMP server, but doesn’t work on the linux master server!?

try{
    $client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', ['trace' => true]);
    $result = $client->checkVat([
        'countryCode' => 'DK',
        'vatNumber' => '47458714'
    ]);
    print_r($result);
}
catch(Exception $e){
    echo $e->getMessage();
}

What am I missing here?! :(

SOAP is enabled

Error

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"/taxation_customs/vies/checkVatService.wsdl"

Call the URL from PHP

Calling the URL from PHP returns error

$wsdl = file_get_contents('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl');
echo $wsdl;

Error

Warning:  file_get_contents(http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl): failed to open stream: HTTP request failed! HTTP/1.0 503 Service Unavailable

Call the URL from command line

Calling the URL from the linux command line HTTP 200 is returned with a XML response

curl http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

3

For some versions of php, the SoapClient does not send http user agent information. What php versions do you have on the server vs your local WAMP?

Try to set the user agent explicitly, using a context stream as follows:

try {
    $opts = array(
        'http' => array(
            'user_agent' => 'PHPSoapClient'
        )
    );
    $context = stream_context_create($opts);

    $wsdlUrl = 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
    $soapClientOptions = array(
        'stream_context' => $context,
        'cache_wsdl' => WSDL_CACHE_NONE
    );

    $client = new SoapClient($wsdlUrl, $soapClientOptions);

    $checkVatParameters = array(
        'countryCode' => 'DK',
        'vatNumber' => '47458714'
    );

    $result = $client->checkVat($checkVatParameters);
    print_r($result);
}
catch(Exception $e) {
    echo $e->getMessage();
}

Edit

It actually seems to be some issues with the web service you are using. The combination of HTTP over IPv6, and missing HTTP User Agent string, seems to give the web service problems.

To verify this, try the following on your linux host:

curl  -A ''  -6 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

this IPv6 request fails.

curl  -A 'cURL User Agent'  -6 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

this IPv6 request succeeds.

curl  -A ''  -4 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
curl  -A 'cURL User Agent'  -4 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl

both these IPv4 request succeeds.

Interesting case :) I guess your linux host resolves ec.europa.eu to its IPv6 address, and that your version of SoapClient did not add a user agent string by default.

MarthyM's user avatar

MarthyM

1,8192 gold badges21 silver badges23 bronze badges

answered Feb 23, 2014 at 19:02

Ivar's user avatar

8

Security issue: This answer disables security features and should not be used in production!

Try this. I hope it helps

$options = [
    'cache_wsdl'     => WSDL_CACHE_NONE,
    'trace'          => 1,
    'stream_context' => stream_context_create(
        [
            'ssl' => [
                'verify_peer'       => false,
                'verify_peer_name'  => false,
                'allow_self_signed' => true
            ]
        ]
    )
];

$client = new SoapClient($url, $options);

0

This issue can be caused by the libxml entity loader having been disabled.

Try running libxml_disable_entity_loader(false); before instantiating SoapClient.

2

It may be helpful for someone, although there is no precise answer to this question.

My soap url has a non-standard port(9087 for example), and firewall blocked that request and I took each time this error:

ERROR — 2017-12-19 20:44:11 —> Fatal Error — SOAP-ERROR: Parsing
WSDL: Couldn’t load from ‘http://soalurl.test:9087/orawsv?wsdl’ :
failed to load external entity «http://soalurl.test:9087/orawsv?wsdl»

I allowed port in firewall and solved the error!

1

Try changing

$client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', ['trace' => true]);

to

$client = new SoapClient('http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', ['trace' => true, 'cache_wsdl' => WSDL_CACHE_MEMORY]);

Also (whether that works or not), check to make sure that /tmp is writeable by your web server and that it isn’t full.

answered Feb 20, 2014 at 21:47

klugerama's user avatar

klugeramaklugerama

3,29219 silver badges25 bronze badges

4

Try enabling openssl extension in your php.ini if it is disabled.
This way I could access the web service without need of any extra arguments, i.e.,

$client = new SoapClient(url);

None of the above works for me, so after a lot of research, I ended up pre-downloading the wsdl file, saving it locally, and passing that file as the first parameter to SoapClient.

Worth mentioning is that file_get_contents($serviceUrl) returned empty response for me, while the url opened fine in my browser. That is probably why SoapClient also could not load the wsdl document. So I ended up downloading it with the php curl library. Here is an example

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $serviceUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$wsdl = curl_exec($ch);
curl_close($ch);

$wsdlFile = '/tmp/service.wsdl';
file_put_contents($wsdlFile, $wsdl);

$client = new SoapClient($wsdlFile);

You can of course implement your own caching policy for the wsdl file, so it won’t be downloaded on each request.

503 means the functions are working and you’re getting a response from the remote server denying you. If you ever tried to cURL google results the same thing happens, because they can detect the user-agent used by file_get_contents and cURL and as a result block those user agents. It’s also possible that the server you’re accessing from also has it’s IP address blackballed for such practices.

Mainly three common reasons why the commands wouldn’t work just like the browser in a remote situation.

1) The default USER-AGENT has been blocked.
2) Your server’s IP block has been blocked.
3) Remote host has a proxy detection.

answered Feb 24, 2014 at 15:20

Madan's user avatar

MadanMadan

6815 silver badges20 bronze badges

After hours of analysis reading tons of logs and internet, finally found problem.

If you use docker and php 7.4 (my case) you probably get error because default security level in OpenSSL it too high for wsdl cert. Even if you disable verify and allow self-signed in SoapClient options.

You need lower seclevel in /etc/ssl/openssl.cnf from DEFAULT@SECLEVEL=2 to

DEFAULT@SECLEVEL=1

Or just add into Dockerfile

RUN sed -i "s|DEFAULT@SECLEVEL=2|DEFAULT@SECLEVEL=1|g" /etc/ssl/openssl.cnf

Source: https://github.com/dotnet/runtime/issues/30667#issuecomment-566482876


You can verify it by run on container

curl -A 'cURL User Agent' -4 https://ewus.nfz.gov.pl/ws-broker-server-ewus/services/Auth?wsdl

Before that change I got error:

SSL routines:tls_process_ske_dhe:dh key too small

It was solved for me this way:

Every company from which you provide «Host» has a firewall.

This error occurs when your source IP is not defined in that firewall.
Contact the server administrator to add the IP.

Or the target IP must be defined in the server firewall whitelist.

Below solution worked for me.

1- Go to php.ini in ubuntu with apache is /etc/php/7.4/apache2
( note: you should use your php version replace by 7.4 )

2- Remove ; from this line ;extension=openssl to make in uncommented.

3- Restart your web server sudo service apache2 restart

I use the AdWords API, and sometimes I have the same problem.
My solution is to add
ini_set(‘default_socket_timeout’, 900);
on the file
vendorgoogleadsgoogleads-php-libsrcGoogleAdsApiAdsSoapClient.php line 65

and in the
vendorgoogleads-php-libsrcGoogleAdsApiAdwordsReportingv201702ReportDownloader.php line 126
ini_set(‘default_socket_timeout’, 900);
$requestOptions[‘stream_context’][‘http’][‘timeout’] = «900»;

Google package overwrite the default php.ini parameter.

Sometimes, the page could connect to ‘https://adwords.google.com/ap
i/adwords/mcm/v201702/ManagedCustomerService?wsdl and sometimes no.
If the page connects once, The WSDL cache will contain the same page, and the program will be ok until the code refreshes the cache…

Adding ?wsdl at the end and calling the method:

$client->__setLocation('url?wsdl'); 

helped to me.

I might have read all questions about this for two days. None of the answers worked for me.

In my case I was lacking cURL module for PHP.

Be aware that, just because you can use cURL on terminal, it does not mean that you have PHP cURL module and it is active.
There was no error showing about it. Not even on /var/log/apache2/error.log

How to install module:
(replace version number for the apropiated one)

sudo apt install php7.2-curl
sudo service apache2 reload

I had the same problem

From local machines everything work (wamp + php5.5.38 or vagrant + php 7.4), but from prod linux server I had error

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl' : failed to load external entity "http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl"

From redirect path plugin in chrome I discovered permanent redirect to https, but change url to https doesnt help.

Status Code    URL    IP    Page Type    Redirect Type    Redirect URL    

301 http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl 147.67.210.30 server_redirect permanent https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl
200 https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl 147.67.210.30 normal none none

After few attempts of different code solutions helped my our server provider. He discovered problem in IP forwarding with ipv6.

http://ec.europa.eu/

Pinging ec.europa.eu [147.67.34.30] with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.

Recommendation was user stream_context_create with socket and bind to 0:0. this forces ipv4

// https://www.php.net/manual/en/context.socket.php

$streamContextOptions = [
  'socket' => [
    'bindto' => '0:0'
  ],
];

$streamContext = stream_context_create($streamContextOptions);

$soapOptions = [
  'stream_context' => $streamContext
];

$service = new SoapClient('https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl', $soapOptions);

I had similar error because I accidently removed attribute
[ServiceContract] from my contract, yet the service host was still opening successfully. Blunders happen

May try to see if the endpoint supports https as well

Есть некий wsdl сервер, допустим «https://192.168.333.3/LNetworkServer/LNetworkServi…» (адрес для поста выдуманный).

В браузере открывается нормально.

Когда пробую использовать SOAP, выдает ошибку:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://sh333skd1-dev/LNetworkServer/LNetworkService.svc?wsdl=wsdl0' : failed to load external entity "https://sh333skd1-dev/LNetworkServer/LNetworkService.svc?wsdl=wsdl0"

Если пробую cURL, ошибок нет, спокойно получаю XML.

Разработчики молчат, дали мне такой код:

$wsdl = "https://192.168.333.3/LNetworkServer/LNetworkService.svc?wsdl";
    	$arrContextOptions=array(
		    'ssl'=>array(
		        'verify_peer'=>false,
		        'verify_peer_name'=>false,
		        'allow_self_signed' => true
		    ),
			'https' => array(
                'curl_verify_ssl_peer'  => false,
                'curl_verify_ssl_host'  => false)
		);
    	$options =array(
	    'trace' => 1,
    	'soap_version' => SOAP_1_1,
    	'location'=>'https://192.168.333.3/LNetworkServer/LNetworkService.svc',
    	'exceptions' => 1,
    	'cache_wsdl'=>WSDL_CACHE_NONE,
    	'verifypeer' => false,
        'verifyhost' => false,
    	'stream_context' => stream_context_create($arrContextOptions),
    	'login'=>'root', 'password'=>'1234' ,
    	'classmap' => array('AcsEmployeeSaveData' => "AcsEmployeeSaveData")
    	);
        //подключение 
	$client = new SoapClient($wsdl, $options);

Сам пробовал такой вариант:

try {
    $opts = array(
		    'ssl'=>array(
		        'verify_peer'=>false,
		        'verify_peer_name'=>false,
		        'allow_self_signed' => true
		    ),
			'https' => array(
                'curl_verify_ssl_peer'  => false,
                'curl_verify_ssl_host'  => false,
            	'user_agent' => 'PHPSoapClient',
                'allow_self_signed' => true
			)
    );
    $context = stream_context_create($opts);

    $wsdlUrl = 'https://192.168.333.3/LNetworkServer/LNetworkService.svc?wsdl';
    $soapClientOptions = array(
	    'trace' => 1,
    	'location'=>'https://192.168.333.3/LNetworkServer/LNetworkService.svc',
    	'exceptions' => 1,
    	'cache_wsdl'=>0,
    	'verifypeer' => false,
        'verifyhost' => false,
    	'stream_context' => $context,
    	'login'=>'root', 'password'=>'1234' ,
    	'classmap' => array('AcsEmployeeSaveData' => "AcsEmployeeSaveData")
    );

    $client = new SoapClient($wsdlUrl, $soapClientOptions);
}
catch(Exception $e) {
	echo $e->getMessage();
}

Оба варианта выдают одинаковую ошибку, описанную выше

SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://sh333skd1-dev/LNetworkServer/LNetworkService.svc?wsdl=wsdl0' : failed to load external entity "https://sh333skd1-dev/LNetworkServer/LNetworkService.svc?wsdl=wsdl0"

В чем проблема?

I’m trying to run a web service using PHP & SOAP, but all I’m getting so far is this:

(SoapFault)[2] message which states: ‘SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://localhost/MyRegistration/login.xml’ : failed to load external entity «http://localhost/MyRegistration/login.xml»

I’ve tried changing localhost to 127.0.0.1, but that makes no difference. login is actually a wsdl file, but if I put login.wsdl in the SOAPClient constructor, it says «‘looks like we got no XML document'» instead.

Here is my code for the SOAP Client (register_client.php):

<?php
try
{
    $sClient = new SoapClient('http://127.0.0.1/MyRegistration/login.wsdl');    

    $param1 = $_POST["regname"];
    $param2 = $_POST["regpass1"];

    $response = $sClient->loginVerify($param1, $param2);    

    var_dump($response);
}
catch(SoapFault $e)
{
    var_dump($e);
}
?> 

And here is the login.wsdl file:

<?xml version="1.0"?>
<definitions name="LoginVal" 
    targetNamespace="urn:LoginVal" 
    xmlns:tns="urn:LoginVal"  
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Login">
  <xsd:element name="getName" type="xsd:string" />
<xsd:element name="getPass" type="xsd:string" />
  <xsd:element name="LoginResponse" type="xsd:string" />          
</xsd:schema>           
  </types>

  <message name="loginVerify">
<part name="username" type="tns:getName" />
<part name="password" type="tns:getPass" />
  </message>

  <message name="doLoginResponse">
<part name="return" type="tns:LoginResponse" />
  </message>  

  <portType name="LoginPort">
    <operation name="loginVerify">
  <input message="tns:loginVerify" />
  <output message="tns:doLoginResponse" />
    </operation>
  </portType>

  <binding name="LoginBinding" type="tns:LoginPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
  <operation name="loginVerify">
    <soap:operation soapAction="urn:LoginAction" />
    <input>
      <soap:body use="encoded" namespace="urn:Login" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />         
    </input>
    <output>
      <soap:body use="encoded" namespace="urn:Login" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />         
    </output>
  </operation>
  </binding>

  <service name="LoginService">
    <port name="LoginPort" binding="tns:LoginBinding">
  <soap:address location="http://localhost/MyRegistration/register.php" />
    </port>
  </service>

</definitions>

And I’m not sure if this is involved, so I’m providing the code for the SOAP Server register.php:

<?php
if(!extension_loaded("soap"))
{
    dl("php_soap.dll");
}

ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("login.wsdl", array('uri'=>'http://127.0.0.1/MyRegistration'))

public function loginVerify($username, $password)
{
    if($_POST["regname"] && $_POST["regemail"] && $_POST["regpass1"] && $_POST["regpass2"] )
    {
        if($_POST["regpass1"] == $_POST["regpass2"])
        {
            $servername = "localhost";
            $username = "root";
            $password = "Hellfire";

            $conn = mysql_connect($servername,$username,"Hellfire")or die(mysql_error());

            mysql_select_db("soap",$conn);

            $sql = "insert into users (name,email,password)values('$_POST[regname]','$_POST[regemail]','$_POST[regpass1]')";

            $result = mysql_query($sql,$conn) or die(mysql_error());

            return "You have registered sucessfully";

            //print "<a href='index.php'>go to login page</a>";
        }
        else return "passwords dont match";
    }
    else return "invalid data";
}

$server->AddFunction("loginVerify");
$server->handle();
?>

I’m sorry if I’m giving unnecessary information, but I’m a complete novice at this — and I’d really appreciate it if someone could point out why exactly this SOAP Fault is being generated, and what I can do to rectify it.

I am using WAMP Server version 2.2, with mySQL 5.5.24 and PHP 5.3.13

@Rkant7767

Hello sir,

I have used this package but, I am getting above mentioned error when trying to launch it.It seems that there is some issue with my configurations.Could you please help me with this????

@nguyenhiepvan

@K2ouMais

I think this issue could be, because Soap isnt sending the user_agent.

I tried to set the user agent in ->options but it still doesnt work.

@nguyenhiepvan

@K2ouMais

Could you please tell us at least how you solved it?

@lichtner

@Rkant7767

@wankimmy

image

solved !

@jesusalvb

I created this controller SoapController.php

<?php

namespace AppHttpControllers;

use ArtisaninwebSoapWrapperSoapWrapper;
use AppSoapRequestGetConversionAmount;
use AppSoapResponseGetConversionAmountResponse;

class SoapController
{
  /**
   * @var SoapWrapper
   */
  protected $soapWrapper;

  /**
   * SoapController constructor.
   *
   * @param SoapWrapper $soapWrapper
   */
  public function __construct(SoapWrapper $soapWrapper)
  {
    $this->soapWrapper = $soapWrapper;
  }

  /**
   * Use the SoapWrapper
   */
  public function show()
  {
    $response = 'empty';

    if(isset($this->soapWrapper)){
        $this->soapWrapper->add('Currency', function ($service) {
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options(['user-agent'=>'PHPSoapClient'])
            ->classmap([
            GetConversionAmount::class,
            GetConversionAmountResponse::class,
            ]);
        });

        $response = $this->soapWrapper->call('Currency.GetConversionAmount', [
        new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000')
        ]);
    }
    echo $response;
  }
}

As the documentation mention I created the Request and Response PHP files
Request appSOAPRequest

<?php

namespace AppSoapRequest;

class GetConversionAmount
{
  /**
   * @var string
   */
  protected $CurrencyFrom;

  /**
   * @var string
   */
  protected $CurrencyTo;

  /**
   * @var string
   */
  protected $RateDate;

  /**
   * @var string
   */
  protected $Amount;

  /**
   * GetConversionAmount constructor.
   *
   * @param string $CurrencyFrom
   * @param string $CurrencyTo
   * @param string $RateDate
   * @param string $Amount
   */
  public function __construct($CurrencyFrom, $CurrencyTo, $RateDate, $Amount)
  {
    $this->CurrencyFrom = $CurrencyFrom;
    $this->CurrencyTo   = $CurrencyTo;
    $this->RateDate     = $RateDate;
    $this->Amount       = $Amount;
  }

  /**
   * @return string
   */
  public function getCurrencyFrom()
  {
    return $this->CurrencyFrom;
  }

  /**
   * @return string
   */
  public function getCurrencyTo()
  {
    return $this->CurrencyTo;
  }

  /**
   * @return string
   */
  public function getRateDate()
  {
    return $this->RateDate;
  }

  /**
   * @return string
   */
  public function getAmount()
  {
    return $this->Amount;
  }
}

Response appSOAPResponse

<?php

namespace AppSoapResponse;

class GetConversionAmountResponse
{
  /**
   * @var string
   */
  protected $GetConversionAmountResult;

  /**
   * GetConversionAmountResponse constructor.
   *
   * @param string
   */
  public function __construct($GetConversionAmountResult)
  {
    $this->GetConversionAmountResult = $GetConversionAmountResult;
  }

  /**
   * @return string
   */
  public function getGetConversionAmountResult()
  {
    return $this->GetConversionAmountResult;
  }
}

Then i call it

Route::get('/soap',[SoapController::class, 'show']);

And I got this error too:

image

I really need to create a SOAP client, I need to create a SOAP client for a BizFlow POC

@jesusalvb

I founded a solution

Here is my controller

<?php

namespace AppHttpControllers;

use ArtisaninwebSoapWrapperSoapWrapper;
use AppSoapRequestGetConversionAmount;
use AppSoapResponseGetConversionAmountResponse;

class SoapController
{
  /**
   * @var SoapWrapper
   */
  protected $soapWrapper;

  /**
   * SoapController constructor.
   *
   * @param SoapWrapper $soapWrapper
   */
  public function __construct(SoapWrapper $soapWrapper)
  {
    $this->soapWrapper = $soapWrapper;
  }

  /**
   * Use the SoapWrapper
   */
  public function show()
  {
    $response = 'empty';
    $opts = array(
        'http' => array(
            'user_agent'=>'PHPSoapClient'
        )
    );
    $context=stream_context_create($opts);
    $wsdl='http://currencyconverter.kowabunga.net/converter.asmx?WSDL';
    $o=array(
        'stream_context'=>$context,
        'cache_wsdl'=>WSDL_CACHE_NONE
    );

    $a=$this->soapWrapper->add('servicio',function($service){
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options([
                'stream_context'=>stream_context_create([
                    'http' => array(
                        'user_agent'=>'PHPSoapClient'
                    )
                ]),
                'cache_wsdl'=>WSDL_CACHE_NONE
            ]);
        dump($service);

    });

   

    $this->soapWrapper->client('servicio',function($client){
        echo '<h3>Functions</h3>';
        dump($client->getFunctions());
        echo'<h3>call</h3>';
        dump($client->call('GetCurrencies',[]));
    });


/*
    if(isset($this->soapWrapper)){
        $this->soapWrapper->client(null,function($service){
            $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->options(['user-agent'=>'PHPSoapClient']);
        });

        $this->soapWrapper->add('Currency', function ($service) {
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options(['user-agent'=>'PHPSoapClient'])
            ->classmap([
            GetConversionAmount::class,
            GetConversionAmountResponse::class,
            ]);
        });

        //*$response = $this->soapWrapper->call('Currency.GetConversionAmount', [
        new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000')
        ])
    }*/

    
    echo $response;
  }
}

And this is the invocation
image

@jesusalvb

You can close it!
The solution is in the options

$this->soapWrapper->add('servicio',function($service){
        $service
            ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL')
            ->trace(true)
            ->options([
                'stream_context'=>stream_context_create([
                    'http' => array(
                        'user_agent'=>'PHPSoapClient'
                    )
                ]),
                'cache_wsdl'=>WSDL_CACHE_NONE
            ]);
        dump($service);

    });

@charmtorio

@Maerryham

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:

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»

Code:

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(
            'http'=>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
        );
        libxml_disable_entity_loader(false);

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


    } catch (Exception $e) {

      $this->forward404($e->getMessage());
    }
  }

asked Jul 10, 2018 at 16:27

Iftikhar uddin's user avatar

Iftikhar uddinIftikhar uddin

2031 gold badge2 silver badges12 bronze badges

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.

answered Jul 16, 2018 at 20:58

Brett's user avatar

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

answered Sep 29, 2021 at 11:48

Twan's user avatar

0

Понравилась статья? Поделить с друзьями:
  • Ошибка parse error как исправить
  • Ошибка parse error syntax error unexpected expecting or
  • Ошибка parse error at line 1 column 1
  • Ошибка parking brake malfunction audi a4 b8
  • Ошибка park brake ауди а6 с6