Jump to content


Photo

External data requests failing

soapclient fopen file_get_contents

  • Please log in to reply
1 reply to this topic

#1 Mahngiel

Mahngiel

    Advanced Member

  • Members
  • PipPipPip
  • 1,076 posts

Posted 25 March 2013 - 03:25 PM

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, 25 March 2013 - 03:30 PM.

?????????????????? This is a signature ????????????????????????

What do you  mean "so please write the code for me . . . "? We aren't here in gleeful anticipation just waiting to write code for you, you know.

CodeIgniter Libraries: Image Lib | Paginator Lib | AJAX Upload

#2 Mahngiel

Mahngiel

    Advanced Member

  • Members
  • PipPipPip
  • 1,076 posts

Posted 26 March 2013 - 12:29 PM

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, 26 March 2013 - 12:29 PM.

?????????????????? This is a signature ????????????????????????

What do you  mean "so please write the code for me . . . "? We aren't here in gleeful anticipation just waiting to write code for you, you know.

CodeIgniter Libraries: Image Lib | Paginator Lib | AJAX Upload




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com