SOAP PHP fault parsing WSDL: failed to load external entity?

前端 未结 12 1783
耶瑟儿~
耶瑟儿~ 2020-11-27 05:37

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

相关标签:
12条回答
  • 2020-11-27 06:21

    I am using selinux and with the following shell command (as root) I was able to allow PHP to make SOAP calls:

    sudo setsebool -P httpd_can_network_connect on
    
    0 讨论(0)
  • 2020-11-27 06:21

    If you use docker there is a chance you get error because of OpenSSL default security level.

    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

    After that change I can run SoapClient without any additional options


    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
    
    0 讨论(0)
  • 2020-11-27 06:24

    Put this code above any Soap call:

    libxml_disable_entity_loader(false);
    
    0 讨论(0)
  • 2020-11-27 06:32

    Just had a similar problem trying to use SoapClient. Everything was working fine but in production, sometimes on page refresh, I would get the "SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from .." error.

    I was using the params:

    new \SoapClient($WSDL, array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => true, "exception" => 0)); 
    

    Removing all the params worked for me:

    new \SoapClient($WSDL); 
    
    0 讨论(0)
  • 2020-11-27 06:33

    try this. works for me

    $options = array(
        'cache_wsdl' => 0,
        'trace' => 1,
        'stream_context' => stream_context_create(array(
              'ssl' => array(
                   'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
              )
        ))
    
    $client = new SoapClient(url, $options);
    
    0 讨论(0)
  • 2020-11-27 06:34

    I had the same problem.

    This php setting solved my problem:

    allow_url_fopen -> 1
    
    0 讨论(0)
提交回复
热议问题