shan169 Posted July 30, 2007 Share Posted July 30, 2007 Hi, I'm looking for the PHP-equivalent of the following java-code: DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = null; doc = db.parse( request.getInputStream() ); locNodes = doc.getElementsByTagName("logicalReader"); //read the stream(a string in xml format) and parse it... Can anyone help plz? Thanks, Shan Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/ Share on other sites More sharing options...
HaLo2FrEeEk Posted July 30, 2007 Share Posted July 30, 2007 Are you looking for something like file_get_contents()? I prefer to use the snoopy library for reading remote pages, but it's all the same. If that is what you are looking for then there you go. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-310735 Share on other sites More sharing options...
shan169 Posted July 30, 2007 Author Share Posted July 30, 2007 hi halo, thanx for ur reply... my page is an action page... wen the other side(which is using java & jsp) opens HttpURLconnection to my page and writes a string(in xml format) to outputstream... my page has to read from the inputstream & look for some tags and get those values and update to a database... So, my page is an action page, i don't open the page in the browser ever... hope this gives a rough idea... Looking for help... Thanx... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-310765 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Then you're looking for a cron job? Something that will automatically run a piece of code at certain preset times or at a certain interval. Right? Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313645 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 ya, this has to run automatically wen someone posts a msg(which is nothing but a string thru HttpUrlConnection in java) to this page... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313678 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Well I'm not sure if Java and php can work together, I don't think you can pass stuff from Java to php. Why not rewrite all the pages in php? It's a better language than Java anyways, I hate Java, I took a class on it for 2 years. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313873 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 dude both r on different sides... so it doesnot matter right? ... i can't control the other side... on my side, in php, i hav to read the data from input stream... i can't find a way to read... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313879 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Well I'm sorry, the two years in Java and I didn't learn anything (becuase the language sucks) so I don't know. I know that you can send POST array data, and SESSION data, but I don't think Java can send POST data to php, it doesn't work like that. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313887 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 no dude, it doesnot matter, whether its php or jsp... it will post to a URL... and my page is PHP, so i need to get the data... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313891 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 And again I'll say it, I'm sorry, dude, I don't know the answer. Show me how Java can create a PHP POST array, Java uses it's own methods of data transfer; remember, I used it for 2 years in an AP class. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313897 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 i don't hav the codes from the other side, and as i said in before posts... Java will write into the outputstream, and in php i must collect from inputstream and it is a string, not array... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313900 Share on other sites More sharing options...
mrjcfreak Posted August 2, 2007 Share Posted August 2, 2007 You basically want to send information out of Java, into PHP, and I understand quite a bit. The best way would be to use a Java module to impersonate a HTTP POST method, and send data to a PHP file as though it's impersonating a HTML form. I would imagine someone somewhere has written an object that does that. Then from the PHP side it's as simple as accessing the $_POST data and parsing the XML using PHP's library for that. Alternatively, you can get Java to output to a file, and have PHP read that, but then you would have to arrange to have the Java tell the PHP to pick it up. PHP can open files over HTTP of the right wrappers are enabled. There are also stream methods in PHP; which you may or may not be able to utilise; http://uk3.php.net/stream would be a good place to start. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313902 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 its ok dude, we all r here, 2 clear our doubts & also others... nthg to be sorry abt... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313904 Share on other sites More sharing options...
mrjcfreak Posted August 2, 2007 Share Posted August 2, 2007 And again I'll say it, I'm sorry, dude, I don't know the answer. Show me how Java can create a PHP POST array, Java uses it's own methods of data transfer; remember, I used it for 2 years in an AP class. Shan mentioned that the data was an XML stream- therefore a data type common to PHP and Java. And everything else. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313906 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 the sad thing, i'm subscribing to a server, it serves many people, so i cant change the existing code at that side, i can only change my side... all others r using JSP to read from inputstream, but i can't find a way to do that in PHP... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313907 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Shan, one of php's data transfer methods for forms is through a POST array, called up like this: $_POST['dataname'] It is an array that you would be passing the data through from Java to php. It might be an XML stream, but can php pick up Java's data transfer methods? Can php read from Java's inputstream? I don't think so. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313912 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 ok, thanx dudes(mrjcfreak & HaLo2FrEeEk ) for ur replies, lets see for few days, if anyone out there got an answer... i can't use $_POST, $_REQUEST because, there is no parameter to specify... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313914 Share on other sites More sharing options...
HaLo2FrEeEk Posted August 2, 2007 Share Posted August 2, 2007 Well, like mrjc said, you could have the Java write to a file then "notify" the php page that the file is updated, have it read the file and then use the contents to update the database. Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313922 Share on other sites More sharing options...
shan169 Posted August 2, 2007 Author Share Posted August 2, 2007 for the time being, i can't ask them to change the code at the server side... if nothing works, then maybe i'll ask them or shift my pages to JSP... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313925 Share on other sites More sharing options...
mrjcfreak Posted August 2, 2007 Share Posted August 2, 2007 Well the stream is going to be just plain ASCII text, isn't it? Does it have an address? What extension does that address have? have you tried googling that extension and the word php? Have you read the stream section in the manual? It seems like a good place to start if you want to open a stream... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314045 Share on other sites More sharing options...
shan169 Posted August 3, 2007 Author Share Posted August 3, 2007 ya, the data in the stream is ascii text... the manual for streams is all like, u open an url & stream the data... but i need the other way... they send to my url and i need to stream the data automatically... so nothing to do with extensions... i don't care who sends, as long as sends a msg to my url, i need to read the stream... Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314687 Share on other sites More sharing options...
mrjcfreak Posted August 3, 2007 Share Posted August 3, 2007 Can you give any details they sent you, or any kind of manual for the system (the jsp program) you are trying to work with? It sounds like they are sending data with http. Can you put a script at the URL they are streaming to containing: <?php file_put_contents("output.txt",var_export($_REQUEST, true)); ?> Then do whatever action will cause the jsp to flush data to the PHP script, and then tell us what "output.txt" has in Quote Link to comment https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314859 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.