SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法加载

时间:2016-06-21 15:42:55

标签: php soap wsdl plesk

使用Plesk 12.5和PHP 7.0.2我收到错误:

SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://<IP ADDRESS>:9443/Configuration?wsdl' : failed to load external entity "https://<IP ADDRESS>:9443/Configuration?wsdl" in <PHP FILE>:51 Stack trace: #0 <PHP FILE>(51): SoapClient->SoapClient('https://<IP FILE>', Array) #1 

它使用来自操作系统的PHP 5.3,但是来自Plesk的PHP我得到了上述错误。

安装了PHP-SOAP,XML。

我使用的代码是:

                try {
                    $configClient = new soapclient("https://{$node["host"]}:{$node["port"]}/Configuration?wsdl",
                            array('login'   => $node["user"],
                            'password'      => $node["pass"],
                            'trace'         => 1,
                            'cache_wsdl'    => WSDL_CACHE_NONE,
                            'features'      => SOAP_SINGLE_ELEMENT_ARRAYS
                            )
                    );

                    $configResponse = $configClient->enableALLProductFeatures();
            } catch (SoapFault $exception) {
                    echo "Problem..... : ";
                    echo $exception;
            }

2 个答案:

答案 0 :(得分:2)

由stream_context选项解决。我的代码现在如下所示:

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

                try {
                $configClient = new soapclient("https://{$node["host"]}:{$node["port"]}/Configuration?wsdl",
                        array('login'   => $node["user"],
                        'password'      => $node["pass"],
                        'trace'         => 1,
                        'cache_wsdl'    => WSDL_CACHE_NONE,
                        'features'      => SOAP_SINGLE_ELEMENT_ARRAYS,
                        'stream_context' => $context
                        )
                );

                $configResponse = $configClient->enableALLProductFeatures();
        } catch (SoapFault $exception) {
                echo "Problem..... : ";
                echo $exception;
        }

答案 1 :(得分:0)

尝试使用curl调试你的连接:

curl -v --user "<login>:<password>" --header "Content-Type: text/xml;charset=UTF-8" --header "SOAPAction:<action>" --data @<file_name> <url_of_the_soap_web_service>