From: <php...@li...> - 2011-02-24 23:06:07
|
Thanks for the answer. IMHI, the manual about java_closure() is not always obvious. ex: 1. function toString() {return "helloWorld";}; 2. $object = java_closure<http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure> (); 3. echo "Java says that PHP says: $object\n"; In this example, no arguments are passed in the java_closure() function. What does java_closure() transform? Only the last object? It is not clear in the manual. ex: 1. function hello() {return "hello";}; 2. echo (string)java_closure<http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure> (null, "hello"); In this example, I think the function hello() is transformed, because "hello" is the second argument. It is a good idea, to change the first line in ... return "helloWorld";}; to prevent confusion with the second argument of java_closure() (PHP developpers are KISS-thinkers :-)). The manual talks about a keymap: maybe give an example? Why is the first argument null? Now, for my case. What is $input? In PHP two classes are declared: class encodeRequest { /** * @var string */ public $applicationName; /** * @var array[1, unbounded] of (object)OriginalDataType */ public $originalData; } class OriginalDataType { /** * @var string */ public $id; /**&; * @var boolean */ public $randomize; /** * @var string */ public $inputData; } $data = new OriginalDataType(); $data->id = 1; $data->randomize= false; $data->inputData = "blabla"; $input = new encodeRequest(); $input->applicationName = "WWM"; $input->originalData = $data; So $input is an instance of the encodeRequest class. I want this PHP instance be transformed in a Java instance. I thought that $java_input = java_closure($input); would do the trick? Sincerely, Koen 2011/2/24 <php...@li...> > Hi, > > > 1. I don't understand the remark: > > "Your java object backed by a php > > instance doesn't have any public methods." > > It's a java.lang.Object which implements no interfaces. Not very > useful unless your library detects that it is a proxy and directly > calls its invocation handler. Please see the java_closure() API for > details at > http://php-java-bridge.sourceforge.net/pjb/docs/php-api/java/_JavaProxy.inc.html#functionjava_closure > > > public static Object[] encode(Object request) throws RuntimeException, > > Exception { > > > > -> I added static: that was logic > > -> I added RuntimeException, like in the FAQ. > > In this case your code will work and I have no explanation for this > issue either. > > But if your library is smart enough to call $java_input's invocation > handler, please have a look at your PHP code called from the > invocation handler. It probably calls a library method which throws an > unchecked exception. > > The problem is simply that an unchecked exception has been returned > from a Java call but not thrown. (You can get around this by setting > JAVA_PREFER_VALUES, but I think you know that). > > > Be it as it may, if you only want to add a sec header to your soap > request, you can do this in PHP as well. Or implement it in Java and > call the entire method from PHP. > > > Regards, > Jost Bökemeier > > > ------------------------------------------------------------------------------ > Free Software Download: Index, Search & Analyze Logs and other IT data in > Real-Time with Splunk. Collect, index and harness all the fast moving IT > data > generated by your applications, servers and devices whether physical, > virtual > or in the cloud. Deliver compliance at lower cost and gain new business > insights. http://p.sf.net/sfu/splunk-dev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > -- *Koen Thomeer*, MD, MSc http://koen.thomeer.be |