Jump to content

External data requests failing


Recommended Posts

Issue:  Retrieving data from remote HTTP locations. "failed to open stream: HTTP request failed!"

Doesn't Work: fopen(), file_get_contents(), SoapClient('[url=]http://remote_wsdl[/url]')

Works: curl, wget via CLI & exec()

Tried: Set all ini's to allow_url_fopen = 'On'

root@OW-WS01:~$ php -v
PHP 5.3.3-7+squeeze15 with Suhosin-Patch (cli) (built: Mar  4 2013 14:05:25) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH

root@OW-WS01:~# php -i --php-ini /etc/php5/apache2/php.ini | grep 'fopen'
allow_url_fopen => On => On

root@OW-WS01:~# grep 'fopen' -R /etc/php5/
/etc/php5/cli/php.ini:; http://php.net/allow-url-fopen
/etc/php5/cli/php.ini:allow_url_fopen = On
/etc/php5/apache2/php.ini:; http://php.net/allow-url-fopen
/etc/php5/apache2/php.ini:allow_url_fopen = On
 

Code Debug:

ini_set('default_socket_timeout', 10);
ini_set('display_errors', 1);
ini_set('error_reporting', E_ALL);

echo 'allow_url_fopen:' .  (ini_get('allow_url_fopen') ? 'TRUE' : 'FALSE') . '<br/>';
echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') . '<br/>';

$Remote_XML  = "valid_path.xml";
$todays_XML     = __DIR__ .'/imports/' . date( 'Ymd', time() ) . '.xml';

echo '<hr/><br/> Testing fopen()<br/>';

$from = fopen( $Remote_XML, 'r' );
$to   = fopen( $todays_XML, 'w+' );
stream_copy_to_stream( $from, $to );

echo '<hr/><br/> Testing file_get_contents()<br/>';

$fgc = file_get_contents($Remote_XML);
file_put_contents($todays_XML, $fgc );

echo '<hr/><br/> Testing SoapClient()<br/>';
 
try{
    $soap = new SoapClient( '/?wsdl', array( 'trace' => TRUE ) );
    $soap->login( 'user', 'pass' );
    echo 'soap passed';
} catch( SoapFault $e ) {
    var_dump($e);
}

phpinfo(INFO_CONFIGURATION);

 

Results in image format: http://i.imm.io/10Hle.png

 

So, how do I overcome this? Have sniffed packets and these requests aren't even getting generated.  This code works just dandy on local and on another server, so there's got to be something I haven't figured out yet. Any idea what could be causing this or what to try next?

 

Thanks

Edited by Mahngiel
Link to comment
Share on other sites

Well, though these issue remain, I have developed a workaround by using cURL() for the downloads and using a hard-copy of the WSDL with these options in the SoapClient constructor

$this->Client = new SoapClient( "path/to/local.wsdl", array( 'soap_version' => 1.1, 'trace' => TRUE, 'stream_context' => 'context' ) );

 

Further, had to remove a schema import from the xml.

 

Am still looking for an answer as to why these changes need to be made.

Edited by Mahngiel
Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.