|
From: <php...@li...> - 2009-01-09 01:00:17
|
Hi folks,
I am using the php-java-bridge to make some remote web services calls.
I'm using the webapp version of the bridge, and I have confirmed it is
working (by visiting localhost:8080/JavaBridge/test.php). I am running
Apache Tomcat 5.5.25 (I also tried on tomcat 5.5.17). It is an older
version of the java bridge (I don't know how to tell what version it is,
but the copyright notice only goes to 2007). This code is running on
x86_64 GNU/Linux, with PHP 5.2.6.
The web service returns a set of bytes, and then my php class needs to
write those bytes to a file (it's a PDF or jpg):
-----------------------
$reportBody = $this->retrieveReport($reportFilename);
if(strlen($reportBody) == 0) {
return "ERROR: unable to retrieve report";
}
// write file
$handle = fopen($pdfDirectory . "/" . $reportFilename,"wb");
if(fwrite($handle,$reportBody) == FALSE) {
...
}
-----------------------
Unfortunately, I'm not able to get the bytes to show up. Instead, in
the file, I get this value:
[[o:array_of_B]:"[B@3a0b2771"]
I looked around the mailing list and found this post:
http://sourceforge.net/mailarchive/message.php?msg_id=215BBBD9D2B80E4E98225471640045918A3356%40CHEXV3.CHBOSTON.ORG
which seemed to indicate I should be able to use 'java_values' to decode
this file.
Using java_values doesn't seem to help--I still see the array_of_B value.
Trying to find the length of the bytes:
error_log($reportBody->length);
causes this error:
"PHP Notice: Trying to get property of non-object "
Use a plain old string works fine:
$str = new java("java.lang.String", "hello");
error_log($str);
outputs "hello".
The same code works on another X86_64 server running Tomcat 5.5.17. The
version of JavaBridge.war is, as far as I can tell, the same (it's the
same size). The same web service is being accessed from this server.
The only difference that I can see is that the other has 'java.so'
uncommented in the php.ini file--why would that matter if I'm using the
web version of the bridge?
Any other suggestions would be appreciated. I've googled around, but
there doesn't seem to be much information regarding byte streams passed
between php and java.
Thanks,
Dan
|