php script calling external php function

82 views
Skip to first unread message

Domen Glušič

unread,
Apr 13, 2011, 11:45:27 AM4/13/11
to Open Wonderland Scripting
Hi guys!

Josmas Flores

unread,
Apr 13, 2011, 12:02:52 PM4/13/11
to open-wonderl...@googlegroups.com
Hi Domen! :)

On 13 April 2011 16:45, Domen Glušič <domen....@gmail.com> wrote:
> Hi guys!

Domen Glušič

unread,
Apr 13, 2011, 12:05:05 PM4/13/11
to Open Wonderland Scripting
Hi guys!

I'm trying to implement soap client via scripting.

I have working php script which consists out of 3 files.
start.php, helloworld1Manager.php and helloworld1Manager.xml

Starting script start.php calls helloworld1Manager.php which gets data
from helloworld1Manager.xml.

I've copied start.php to scripting module mouse1.php. When I'm trying
to run script I'm getting following java console output:




java console output:
ScriptingComponent : Cell 10 : General exception in the whole
mechanism of compiling and executing the script
com.caucho.quercus.QuercusErrorException: /home/domeng/
helloworld1Manager.php:3: Fatal Error: 'class_exists' is an unknown
function.
com.caucho.quercus.QuercusErrorException: /home/domeng/
helloworld1Manager.php:3: Fatal Error: 'class_exists' is an unknown
function.
at com.caucho.quercus.env.Env.error(Env.java:4480)
at com.caucho.quercus.env.Env.error(Env.java:4391)
at com.caucho.quercus.env.Env.error(Env.java:4085)
at com.caucho.quercus.expr.FunctionExpr.evalImpl(FunctionExpr.java:
165)
at com.caucho.quercus.expr.FunctionExpr.eval(FunctionExpr.java:126)
at com.caucho.quercus.expr.Expr.evalBoolean(Expr.java:468)
at com.caucho.quercus.expr.NotExpr.evalBoolean(NotExpr.java:72)
at com.caucho.quercus.program.IfStatement.execute(IfStatement.java:
80)
at
com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:
105)
at
com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:
272)
at
com.caucho.quercus.page.InterpretedPage.execute(InterpretedPage.java:
70)
at com.caucho.quercus.env.Env.include(Env.java:3730)
at com.caucho.quercus.env.Env.includeOnce(Env.java:3679)
at com.caucho.quercus.expr.IncludeOnceExpr.eval(IncludeOnceExpr.java:
88)
at
com.caucho.quercus.program.ExprStatement.execute(ExprStatement.java:
64)
at
com.caucho.quercus.program.BlockStatement.execute(BlockStatement.java:
105)
at
com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:
272)
at
com.caucho.quercus.script.QuercusCompiledScript.eval(QuercusCompiledScript.java:
93)
at javax.script.CompiledScript.eval(CompiledScript.java:75)
at
org.jdesktop.wonderland.modules.scriptingComponent.client.ScriptingComponent.executeScript(ScriptingComponent.java:
2618)
at
org.jdesktop.wonderland.modules.scriptingComponent.client.ScriptingComponent
$MouseEventListener.computeEvent(ScriptingComponent.java:4033)
at
org.jdesktop.wonderland.client.input.EventListenerBaseImpl.compute(EventListenerBaseImpl.java:
242)
at org.jdesktop.mtgame.ProcessorThread.run(ProcessorThread.java:121)






start.php script code:

<?php



require_once "helloworld1Manager.php";



$myhelloparam = new helloparam();

$myhelloparam->parameter1 = "Domen";

$myhelloparam->parameter2 = "Glusic";




$myhelloworld1Manager = new helloworld1Manager();

$resultMessage = $myhelloworld1Manager->helloworld1($myhelloparam);

print_r ($resultMessage);





?>


helloworld1Manager.php script code:

<?php



if (!class_exists("helloparam")) {

/**

* helloparam

*/

class helloparam {

/**

* @access public

* @var string

*/

public $parameter1;

/**

* @access public

* @var string

*/

public $parameter2;

}}



if (!class_exists("helloworld1Manager")) {

/**

* helloworld1Manager

* @author WSDLInterpreter

*/

class helloworld1Manager extends SoapClient {

/**

* Default class map for wsdl=>php

* @access private

* @var array

*/

private static $classmap = array(

"helloparam" => "helloparam",

);



/**

* Constructor using wsdl location and options array

* @param string $wsdl WSDL location for this service

* @param array $options Options for the SoapClient

*/

public function __construct($wsdl="helloworld1Manager.xml",
$options=array()) {

foreach(self::$classmap as $wsdlClassName => $phpClassName) {

if(!isset($options['classmap'][$wsdlClassName])) {

$options['classmap'][$wsdlClassName] = $phpClassName;

}

}

parent::__construct($wsdl, $options);

}



/**

* Checks if an argument list matches against a valid argument type
list

* @param array $arguments The argument list to check

* @param array $validParameters A list of valid argument types

* @return boolean true if arguments match against validParameters

* @throws Exception invalid function signature message

*/

public function _checkArguments($arguments, $validParameters) {

$variables = "";

foreach ($arguments as $arg) {

$type = gettype($arg);

if ($type == "object") {

$type = get_class($arg);

}

$variables .= "(".$type.")";

}

if (!in_array($variables, $validParameters)) {

throw new Exception("Invalid parameter types: ".str_replace(")
(", ", ", $variables));

}

return true;

}



/**

* Service Call: helloworld1

* Parameter options:

* (helloparam) helloparam

* @param mixed,... See function description for parameter options

* @return string

* @throws Exception invalid function signature message

*/

public function helloworld1($mixed = null) {

$validParameters = array(

"(helloparam)",

);

$args = func_get_args();

$this->_checkArguments($args, $validParameters);

return $this->__soapCall("helloworld1", $args);

}





}}



?>

Morris Ford

unread,
Apr 13, 2011, 1:27:19 PM4/13/11
to open-wonderl...@googlegroups.com
It would appear that 'class_exists' is not available in the Quercus php code. When I was setting up the Scripting Component I did only minimal testing with the various languages so getting this type of error is not terribly surprising. You will probably need to look for php module(s) that support the functions you want and 'import' those. Please report back how it goes. I would be very interested in the process that you have to go through and I will help if I can.
Morris

Domen Glušič

unread,
Apr 14, 2011, 6:47:03 AM4/14/11
to Open Wonderland Scripting
Thank you. How exactly can I import other module than quercus?
I've checked some quercus examples and require_once (method that
includes other php file) should be supported in theory...

Soap clients with similar file structure also exists in javascript.
Just in case if that php one wont work. Did you do some testing when
main function written in javascript calls external javascript
function ?

Best regards
Domen


On Apr 13, 7:27 pm, Morris Ford <morrishf...@gmail.com> wrote:
> It would appear that 'class_exists' is not available in the Quercus php
> code. When I was setting up the Scripting Component I did only minimal
> testing with the various languages so getting this type of error is not
> terribly surprising. You will probably need to look for php module(s) that
> support the functions you want and 'import' those. Please report back how it
> goes. I would be very interested in the process that you have to go through
> and I will help if I can.
> Morris
>

Morris Ford

unread,
Apr 14, 2011, 9:07:59 AM4/14/11
to open-wonderl...@googlegroups.com
I found this reference http://www.java2s.com/Open-Source/Java-Document/EJB-Server-resin-3.1.5/quercus/com/caucho/quercus/lib/ClassesModule.java.java-doc.htm that shows 'class_exists' with three parameters. Is that significant? Regrettably, I have very little experience with php.
Morris

Domen Glušič

unread,
Apr 19, 2011, 12:00:34 PM4/19/11
to Open Wonderland Scripting
Hi!

I've found out that quercus doesn't support(include) soapclient.
That's why my code's not working.
What exactly I have to do to implement other php client? One
supporting soapclient is Project zero http://www.projectzero.org/php/



Domen


On Apr 14, 3:07 pm, Morris Ford <morrishf...@gmail.com> wrote:
> I found this referencehttp://www.java2s.com/Open-Source/Java-Document/EJB-Server-resin-3.1....
> shows 'class_exists' with three parameters. Is that significant?
> Regrettably, I have very little experience with php.
> Morris
>

Morris Ford

unread,
Apr 19, 2011, 12:57:18 PM4/19/11
to open-wonderl...@googlegroups.com
In order to use a different php scripting engine:

The php implementation must support java scripting interface (jsr-223). I could not determine if the project zero package supports jsr-223.
Since both scripting engines would respond as php engines the Quercus jars must be removed. To do this remove the quercus.jar and resin-util.jar files from the lib directory inside the scripting component.
Insert the new php jar files into that lib directory. There are usually two jar files for a jsr-223 implementation, a language jar and an engine jar.
If a php script runs then everything is good.

Morris
Reply all
Reply to author
Forward
0 new messages