简体   繁体   中英

java.lang.String cannot be cast to java.io.InputStream

I'm writing a php script which is interfacing with a SOAP client (which is internally using java).

One of the calls requires that I pass Base64 encoded content.

I'm passing it like this:

(Edit 1)
$content=file_get_contents('fileX'); 
fileX is a binary file which has been uploaded via POST and saved successfully in /tmp.
It is ~600kb in binary form.

$args[]=array('name'=>'content', 'value'=>base64_encode($content), 'type'=>'Base64Binary');

But, I'm getting an error:

java.lang.String cannot be cast to java.io.InputStream


(Edit2)
The documentation of the third party application says exactly:
Parameter   Description                               Type
filename    The name of the presentation file         String
            including the file extension. 
content     The content of the presentation file      Base64Binary
            encoded in Base64 scheme. 

The second parameter in the array is of type String, due to the output type of base64_decode . That Java error implies that it is expecting an object of type InputStream.

You may need to use the Zend PHP Java Bridge as seen here:

https://fosswiki.liip.ch/display/~chregu/Convert+PHP+String+to+a+Java+InputStream

in order to convert that String to a Java InputStream.

Download Zend Server here:

http://www.zend.com/en/products/server/downloads

or an alternative PHP Java Bridge here:

http://php-java-bridge.sourceforge.net/pjb/installation.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM