note 91451 modified in java.examples by danbrown
| From: | danbrown@php.net | Date: | Wed, 10 Jun 2009 17:34:02 +0000 |
| Subject: | note 91451 modified in java.examples by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156751@lists.php.net to get a copy of this message | ||
PHP JavaBridge to work with PHP5 - windows server:
steps:
1- Install Java J2EE 1.5 + JDK 1.4 (which includes application server/deploy tool/etc...)
2- download pecl-5.0.5-Win32.zip and php-java-bridge_2.0.8.zip, which will include
extra dll(s)
- unpack pecl pkg to your extensions folder, in PHP5 its ext.
- unpack java-Bridge to root php folder, in my case its simply C:\PHP
Note: the java-Bridge inculdes new versions of certain files like php_java.dll
so, it would be wise to rename your old files that came with PECL pkg for example
file_old, to rollback at anytime.
In order to deploy/test Java-Bridge .war onto your java application server follow these steps
http://cvs.sourceforge.net/viewcvs.py/php-java-bridge/php-java-bridge/
INSTALL.WINDOWS?view=markup
Note: move JavaBridge.jar to your extensions folder. and in test.php file that came
with Java-Brdige package change line java_require("test/arrayToString.jar");
to java_require("tests.php4/arrayToString.jar");
Add the following to your php.ini file and restart server:-
java.classpath = "location of JavaBridge.jar file...i.e. to your PHP extensions folder\
JavaBridge.jar,also any other extra java files that you'll be instanciating using your php
script"
java.java_home = "location of jdk\bin"
java.libpath = "location of php_java.dll file...i.e. also to your PHP extensions folder"
This example uses the PHP/Java Bridge to connect to a SOAP service.
////////////////////////////////////////////////////////////////////
#!/bin/env php
<?php
require_once("java/Java.inc");
include("wsimport.php");
try {
$addNumbersService = new java("org.duke.AddNumbersService");
$port = $addNumbersService->getAddNumbersPort();
$number1 = 10;
$number2 = 20;
echo ("Invoking one-way operation. Nothing is returned from service.\n");
$port->oneWayInt($number1);
echo ("Invoking addNumbers($number1, $number2)\n");
$result = $port->addNumbers($number1, $number2);
echo ("The result of adding $number1 and $number2 is $result\n\n");
$number1 = -10;
echo ("Invoking addNumbers($number1, $number2)\n");
$result = $port->addNumbers($number1, $number2);
echo ("The result of adding $number1 and $number2 is $result\n\n");
} catch (JavaException $ex) {
$ex = $ex->getCause();
if (java_instanceof($ex, java("org.duke.AddNumbersFault_Exception"))) {
$info = $ex->getFaultInfo()->getFaultInfo ();
echo ("Caught AddNumbersFault_Exception: $ex, INFO: $info.\n");
} else {
echo ("Exception occured: $ex\n");
}
}
?>
--was--
PHP JavaBridge to work with PHP5 - windows server:
steps:
1- Install Java J2EE 1.5 + JDK 1.4 (which includes application server/deploy tool/etc...)
2- download pecl-5.0.5-Win32.zip and php-java-bridge_2.0.8.zip, which will include
extra dll(s)
- unpack pecl pkg to your extensions folder, in PHP5 its ext.
- unpack java-Bridge to root php folder, in my case its simply C:\PHP
Note: the java-Bridge inculdes new versions of certain files like php_java.dll
so, it would be wise to rename your old files that came with PECL pkg for example
file_old, to rollback at anytime.
In order to deploy/test Java-Bridge .war onto your java application server follow these steps
http://cvs.sourceforge.net/viewcvs.py/php-java-bridge/php-java-bridge/
INSTALL.WINDOWS?view=markup
Note: move JavaBridge.jar to your extensions folder. and in test.php file that came
with Java-Brdige package change line java_require("test/arrayToString.jar");
to java_require("tests.php4/arrayToString.jar");
Add the following to your php.ini file and restart server:-
java.classpath = "location of JavaBridge.jar file...i.e. to your PHP extensions folder\
JavaBridge.jar,also any other extra java files that you'll be instanciating using your php
script"
java.java_home = "location of jdk\bin"
java.libpath = "location of php_java.dll file...i.e. also to your PHP extensions folder"
http://php.net/manual/en/java.examples.php