SOAP-ERROR:解析 WSDL:无法从

Posted

技术标签:

【中文标题】SOAP-ERROR:解析 WSDL:无法从【英文标题】:SOAP-ERROR: Parsing WSDL: Couldn't load from 【发布时间】:2014-12-30 06:01:22 【问题描述】:

我正在我的网络应用程序中集成 google Adwords API,我在执行我的 php 文件时遇到错误,即

错误:

Warning: curl_setopt(): CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php on line 187 
SoapFault Object ( [message:protected] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl' : 
failed to load external entity "https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl" 
    [string:Exception:private] => [code:protected] => 0 [file:protected] => /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php [line:protected] => 219
    [trace:Exception:private] => Array ( [0] => Array ( 
                                                        [file] => /var/www/vhosts/healthcampaign.in/httpdocs/smscampaign/pages/FacebookAds.php [line] => 219 
                                                        [function] => SoapClient 
                                                        [class] => SoapClient 
                                                        [type] => -> [args] => Array ( 
                                                                                        [0] => https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl 
                                                                                        [1] => Array ( [trace] => 1 ) 
                                                                                        ) 
                                                    ) 
    ) 
    [previous:Exception:private] => [faultstring] => SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl' : 
    failed to load external entity "https://adwords-sandbox.google.com/api/adwords/cm/v201406/CampaignService?wsdl" [faultcode] => WSDL )

【问题讨论】:

【参考方案1】:

问题在于 SSL。如果您在本地测试 API 并遇到此错误,请尝试快速检查 - 在 AdWords PHP SDK 中找到名为 AdsSoapClientFactory.php 的文件并在第 142 行附近更新以添加 && false

// SSL settings.
if ($soapSettings->getSslVerify() === true && false)  // explicitly disable SSL Verify

在该代码行下方也有一些有用的 cmets。当然,不建议对生产系统禁用 SSL 验证,但至少这是一个快速的解决方案,不会让您对为什么该死的 API 不想要工作而失去理智。

如果这确实解决了问题,请考虑使用 SoapSettings 实现它。撤消对AdsSoapClientFactory.php 的更改,并在主文件中添加:

use Google\AdsApi\Common\SoapSettingsBuilder;
[...]
$soapSettings= (new SoapSettingsBuilder())
    ->disableSslVerify()
    ->build();

$session = (new AdWordsSessionBuilder())
    ->fromFile()
    ->withOAuth2Credential($oAuth2Credential)
    ->withSoapSettings($soapSettings)
    ->build();

【讨论】:

以上是关于SOAP-ERROR:解析 WSDL:无法从的主要内容,如果未能解决你的问题,请参考以下文章

PHP SoapClient over selfsigned certificate,SOAP-ERROR:解析WSDL:无法从'https://加载

SOAP-ERROR:解析WSDL:无法找到 在

PHP 中的 SoapClient 错误回退

无法使用jaxb2-maven-plugin将WSDL解析为不同的包

wsimport在解析WSDL时遇到问题

无法解析WSDL - 没有这样的文件或目录