php SOAP 错误:解析 WSDL:无法从 <URL> 加载

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11082889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:42:59  来源:igfitidea点击:

SOAP-ERROR: Parsing WSDL: Couldn't load from <URL>

phpsoaphttps

提问by Gyaneshwar Pardhi

In PHP: I am getting an error:

在 PHP 中:我收到一个错误:

SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxxx.asmx?WSDL' : failed to load external entity "http://xxx.xxxx.asmx?WSDL"

SOAP 错误:解析 WSDL:无法从“ http://xxx.xxxx.asmx?WSDL”加载:无法加载外部实体“ http://xxx.xxxx.asmx?WSDL

My code is:

我的代码是:

<?php
header('Content-Type: text/plain');
if (!class_exists('SoapClient')) {
    die ("You haven't installed the PHP-Soap module.");
}

ini_set('max_execution_time', 1);
try {
    $options = array(
        'soap_version' => SOAP_1_2,
        'exceptions'   => true,
        'trace'        => 1,
        'cache_wsdl'   => WSDL_CACHE_NONE
    );
    $client = new SoapClient('http://xxx.xxxx.asmx?WSDL', $options);
    // Note where 'CreateIncident' and 'request' tags are in the XML
    $results = $client->CreateIncident(
        array(
            'FirstName'         => 'gyaan',
            'LastName'          => 'p',
            'Email'             => '[email protected]',
            'QueryProductClass' => 'QueryProductClass',
            'ChannelCode'       => 12,
            'CampaignCode'      => 234,
            'Lob'               => 'Lob',
            'PackageName'       => 'SEONI',
            'PackageCode'       => 'SMP',
            'TravelYear'        => 2012,
            'TravelMonth'       => 06,
            'TravelDay'         => 29,
            'CityOfResidence'   => 'Jabalpur',
            'ncidentNotes'      => 'testing ignor this',
            'MobilePhone'       => '1234567890',
            'DepartureCity'     => 'bangalore',
            'NoOfDaysTravel'    => '3 Days',
            'VendorName'        => 'TEST HIQ'
        )
    );
}
catch (Exception $e) {
    echo "<h2>Exception Error!</h2>";
    echo $e->getMessage();
}
?>

Please tell me where i am making mistake i am new in WSDL and soap

请告诉我哪里出错了我是 WSDL 和肥皂新手

回答by adamdport

I solved this on my WAMP setup by enabling the php_opensslextension, since the URL I was loading from used https://.

我通过启用php_openssl扩展在我的 WAMP 设置中解决了这个问题,因为我从 used 加载的 URL https://

回答by Lee Henkel

I had exactly the same error message. In my case, making an entry in my /etc/hostsfile (on the server hosting the service) for the target server referenced in the WSDL fixed it.

我有完全相同的错误消息。就我而言,在我的/etc/hosts文件中(在托管服务的服务器上)为 WSDL 中引用的目标服务器创建一个条目修复了它。

Kind of a strangely worded error message..

一种措辞奇怪的错误消息..

回答by minhnguyen

I had this problem and it took me hours to figure out. The mainly reason of this error is the SoapClient cannot stream the web service file from the host. I uncommented this line "extension=php_openssl.dll" in my php.ini file and it works.

我遇到了这个问题,我花了几个小时才弄清楚。此错误的主要原因是 SoapClient 无法从主机流式传输 Web 服务文件。我在我的 php.ini 文件中取消了这一行“extension=php_openssl.dll”的注释,它可以工作。

回答by Rohit Dhiman

Try this:

尝试这个:

$Wsdl = 'http://xxxx.xxx.xx/webservice3.asmx?WSDL';
libxml_disable_entity_loader(false); //adding this worked for me
$Client = new SoapClient($Wsdl);
//Code...

回答by T.Todua

If you want to use that on localhost, then use WAMP.

如果您想在本地主机上使用它,请使用 WAMP。

Then click on tray icon>PHP Services> and there enable the followings:

然后单击托盘图标>PHP 服务> 并启用以下内容:

  • SOAP
  • php_openssl
  • openssl
  • curl
  • 肥皂
  • php_openssl
  • openssl
  • 卷曲

p.s. some free web-hosting may not have those options

ps 一些免费的网络托管可能没有这些选项

回答by jahson kimulu

Try adding this piece of code. It worked for me.

尝试添加这段代码。它对我有用。

$opts = array(
    'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)
);
// SOAP 1.2 client
$params = array ('encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts) );
$url = "http://www.webservicex.net/globalweather.asmx?WSDL";

try{
 $client = new SoapClient($url,$params );
}
catch(SoapFault $fault) {
 echo '<br>'.$fault;
}

回答by Jose Daniel

I got the same error and I solved it looking for the soap settings in the php.ini file and changing soap.wsdl_cache_enabled=1to soap.wsdl_cache_enabled=0

我遇到了同样的错误,我解决了它,在 php.ini 文件中查找soap设置并将soap.wsdl_cache_enabled=1更改为soap.wsdl_cache_enabled=0

回答by vijaymmali

Enable all these from php.iniconfiguration file

php.ini配置文件启用所有这些

extension=php_openssl.dll
extension=php_curl.dll
extension=php_xmlrpc.dll

回答by curzduff

add the dns entry to your system hosts file
for example:http://aaa.com/service.asmx?WSDL
you can get the aaa.com's ip address with ping
and then add to the hosts file

将dns条目添加到你的系统hosts文件
中例如:http://aaa.com/service.asmx?WSDL
你可以ping得到aaa.com的ip地址
然后添加到hosts文件中

回答by saiid

I got the same error

我遇到了同样的错误

Could not connect to the Magento WebService API: SOAP-ERROR: Parsing WSDL: Couldn't load from 'example.com/api/soap/?wsdl' : failed to load external entity "example.com/api/soap/?wsdl"

无法连接到 Magento WebService API:SOAP-ERROR:解析 WSDL:无法从“example.com/api/soap/?wsdl”加载:无法加载外部实体“example.com/api/soap/?wsdl ”

and my issue resolved once I update my Magento Root URL to

一旦我将 Magento 根 URL 更新为

example.com/index.php/api/soap/?wsdl

example.com/index.php/api/soap/?wsdl

Yes, I was missing index.php that causes the error.

是的,我缺少导致错误的 index.php。