Jump to content

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/
Share on other sites

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...

 

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-310765
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313902
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313906
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-313912
Share on other sites

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...

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314045
Share on other sites

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...

 

 

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314687
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/62438-getinputstream-in-php/#findComment-314859
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.