0

I am building an app using SOAP/web services to interact with a Java API. All was going swimmingly until now.

I need to pass an output stream as a param to a Java method from PHP. I am pretty sure I need to use PHP output buffering and fwrite, I am just not sure how to go about it.

I know you can use Java in php by using $myJavaFromPHP = new Java ... but I would prefer not to do it that way if at all possible*.

If it helps any, the parameter specs in java is a base64 encoded, content-type of application/octet-stream.

So, is this possible? If so, what is the best way to do it?

*I am trying to do this in regular PHP, w/ no dependencies. But if using PHP's Java class is the only way to do it, how?

2
  • Also, I have never really used streams before. So any info helps. Thanks. Commented Jul 11, 2009 at 15:02
  • what SOAP/WS stack are you using (i.e. Axis, Axis2, JBoss-WS, Metro, CXF, etc)? Commented Jul 11, 2009 at 17:41

1 Answer 1

1

You somehow need a running Java Virtual Machine to execute the Java code. If it is already running "somewhere" you need to call that, and if you need help with that you must describe your environment better.

If the output is rather small it might be beneficial to have a small Java method which invokes the API you need, and collect the output in a String (using a ByteArrayOutputStream or a StringWriter) which you then return to the PHP caller.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.