0

我有一个奇怪的情况,我可以通过普通的 Web 浏览器 URL 获取 URL $wsdl = ' https://www.connectwebservice.com/sandbox1_test/services/IR?wsdl购买将路径放入 URL 栏中,但我不能似乎通过连接也file_get_contents()不会返回任何内容,尽管相同的代码在其他连接上也可以正常工作。

如果这对将来的任何人有帮助,我已经建立了一些错误诊断代码......

<?php
ini_set('display_errors', 'On');
ini_set('memory_limit','1000M');
ini_set("soap.wsdl_cache_enabled", "0"); 
ini_set("default_socket_timeout", 120);  
ini_set("track_errors","On");
error_reporting(E_ALL);

$days = 7;  
$date = date('d/m/Y 00:00', (time() - ($days * 24 * 60 * 60))); 

$soap_args = array(
    'exceptions'=>true,
    'cache_wsdl'=>WSDL_CACHE_NONE,
    'trace'=>true,
    'connection_timeout'=>120,
    );

$wsdl = 'https://www.connectwebservice.com/sandbox1_test/services/IR?wsdl'; 

if(file_get_contents($wsdl)){

    try {

        $client = new SoapClient($wsdl,$soap_args);

        $product = $client->getProductIdsChangedSinceDateStrForType(array("lastRequestDateStr" => $date, "leafOnly" => true))->getProductIdsChangedSinceDateStrForTypeReturn;       

    } catch (SoapFault $fault) {
        var_dump(libxml_get_last_error());
        ?><br/><br/><pre><?php var_dump($fault); ?></pre><?php
        echo "<br/><br/>----------------------<br/><br/>";
        echo "Reason:   ";
        trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);

    }

    //show results if posible

    if($client){


        if ($product != '') { 
            $product = split(',', $product); 
            ?>Products:<br/><br/><pre><?php print_r($productIds); ?></pre><?php
            echo "<br/><br/>----------------------<br/><br/>";
        }

    } else {
        echo "$client only?";           
    }

    ?><br/><br/>Client:<br/><br/><pre><?php print_r($client); ?></pre>

    <?php

} else {
    echo "<br/>no connection or bad url";
}

`

4

1 回答 1

0

检查是否allow-url-fopen设置truephp.ini

http://es2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

于 2013-03-13T16:39:24.793 回答