Receiving XML with file_get_contents() not working

Receiving XML with file_get_contents() not working

Postby raytaylorii on Mon Feb 13, 2012 3:53 pm

I put this question here because I think the problem is in the PHP.INI file...
I am trying to create a web service that sends an xml response back to a client request. The problem I am having is when I execute the client request, the browser hangs and eventually comes back with a server time out error. I have checked the PHP.INI settings to make sure allow_url_fopen is set to on. I am hosting the website on an IBM i using Zend Server. I tried using the CURL functions and that doesn't work either. Any suggestions what to check for in PHP.INI?
Thanks,
Ray

Server side: file name is XML3.php
<?php
ob_start();
header("Content-Type:text/xml");
echo "<?xml version='1.0' encoding='UTF-8' ?>";
echo '<posts>';
echo '<post>';
echo "<title>title1</title>";
echo "<body>this is the body</body>";
echo "<post_date>02/10/2012</post_date>";
echo '</post>';
echo '</posts>';
ob_end_flush();

?>


Client side:

<?php
$xml = file_get_contents('http://corvetteamericadealers.com/dev1/Examples/XML3.php');
$sxe = new SimpleXMLElement($xml);
var_dump($sxe);
raytaylorii
 
Posts: 26
Joined: Tue Sep 29, 2009 4:35 pm

Re: Receiving XML with file_get_contents() not working

Postby erich_hieden on Mon Feb 13, 2012 4:03 pm

Which side is on IBM i? Client or Server?

Do you get any messages in your PHP log?

I have to admit, that I can't see any problem here, it's running perfectly well over here, without doing any changes in php.ini
erich_hieden
 
Posts: 347
Joined: Tue Jul 07, 2009 9:01 am

Re: Receiving XML with file_get_contents() not working

Postby raytaylorii on Mon Feb 13, 2012 4:14 pm

IBM i is the server side. I looked in Zend Server event screen and it says "Maximum execution time of 30 seconds exceeded"
raytaylorii
 
Posts: 26
Joined: Tue Sep 29, 2009 4:35 pm

Re: Receiving XML with file_get_contents() not working

Postby aseiden on Tue Feb 14, 2012 3:45 am

Ray, your PHP code is correct--I was able to test it from my own host--so I'm wondering if the issue is a DNS error, or some other routing problem, or a firewall restriction. Are both machines within your firewall?

As a simple test that might reveal something, point the file_get_contents() to google.com or another "neutral" site (if you don't consider google neutral, use another one), to test the ability of your script to access other servers. Or try an IP address instead of a domain name.

Alan
aseiden
 
Posts: 697
Joined: Thu Apr 09, 2009 5:45 pm

Re: Receiving XML with file_get_contents() not working

Postby erich_hieden on Wed Feb 15, 2012 10:20 am

raytaylorii wrote:IBM i is the server side. I looked in Zend Server event screen and it says "Maximum execution time of 30 seconds exceeded"


IIRC the error log tells you which file and line the script is when running into timeout. Would be helpful to see the whole error message.
erich_hieden
 
Posts: 347
Joined: Tue Jul 07, 2009 9:01 am

Re: Receiving XML with file_get_contents() not working

Postby raytaylorii on Wed Feb 22, 2012 3:18 pm

The Zend Support team helped me resolve this. I changed the url name to the IP address of the IBM i and it worked fine. So, corvetteamericadealers.com changed to 192.168.0.7 and the script worked fine.
raytaylorii
 
Posts: 26
Joined: Tue Sep 29, 2009 4:35 pm

Re: Receiving XML with file_get_contents() not working

Postby erich_hieden on Wed Feb 22, 2012 4:57 pm

Then your IBM i has problems resolving domain names. Try ping 'corvetteamericadealers.com' from a 5250 session. I suppose that it won't work. You can configure DNS with CFGTCP -> 12 (= CHGTCPDMN).
erich_hieden
 
Posts: 347
Joined: Tue Jul 07, 2009 9:01 am


Return to Zend Server for IBM i

Who is online

Users browsing this forum: No registered users and 0 guests