[英]How can I get a java.io.InputStream from a java.lang.String?
[英]java.lang.String cannot be cast to java.io.InputStream
我正在寫一個與SOAP客戶端(內部使用Java)接口的php腳本。
其中一項電話要求我傳遞Base64編碼的內容。
我通過這樣的傳遞:
(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');
但是,我收到一個錯誤:
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.
由於base64_decode
的輸出類型,數組中的第二個參數的類型為String。 該Java錯誤表明它正在期待一個InputStream類型的對象。
您可能需要使用Zend PHP Java Bridge,如下所示:
https://fosswiki.liip.ch/display/~chregu/Convert+PHP+String+to+a+Java+InputStream
為了將該String轉換為Java InputStream。
在此處下載Zend Server:
http://www.zend.com/cn/products/server/downloads
或此處的替代PHP Java Bridge:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.