You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-user@xml.apache.org by Tom Myers <to...@dreamscape.com> on 2001/04/26 01:13:36 UTC

InvokeBSF with ActiveScriptEngine?

The org.apache.soap.server.InvokeBSF.service(..) method uses
>       BSFManager mgr = (BSFManager) target;
>       BSFEngine eng = mgr.loadScriptingEngine (dd.getScriptLanguage ());
>       Object result = eng.call (null, methodName, args);

which works just fine on Rhino javascript, e.g. the Calculator example; but
has anybody made this work with the ActiveScript languages vbscript, jscript?
Looking at the BSF-2_2 package com.ibm.bsf.engines.activescript, I see that

   ActiveScriptEngine.call(Object object, String method, Object[] args)

starts with object.toString(), so I would think it is always going to 
generate a nullPointerException if called by InvokeBSF.service(...)
and that is indeed what I see when I try to call it that way, within SOAP or 
just using an eng.call(null,...) as a modified BSF example.

Has anybody done an ActiveScriptEngine-based script service in Apache SOAP?

The RPCRouter class calls on invokeBSF.service via
>         Class bc = Class.forName ("org.apache.soap.server.InvokeBSF");
...
>         Method m = MethodUtils.getMethod (bc, "service", sig, true);
>         result = (Bean) m.invoke (null, new Object[] {dd, targetObject, 
>                                                       call.getMethodName (),
>                                                       args});

and of course the null in that "m.invoke (null" is fine, it's a static
method, but the null within "eng.call (null" seems to be a problem. Am I
missing something obvious again? I usually do.

Tom Myers


---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org


Re: InvokeBSF with ActiveScriptEngine...bug workaround/fix?

Posted by Tom Myers <to...@dreamscape.com>.
As I said at 07:13 PM 4/25/2001 -0400,

>The org.apache.soap.server.InvokeBSF.service(..) method uses
> >       BSFManager mgr = (BSFManager) target;
> >       BSFEngine eng = mgr.loadScriptingEngine (dd.getScriptLanguage ());
> >       Object result = eng.call (null, methodName, args);
>
>which works just fine on Rhino javascript, e.g. the Calculator example; but
it blows up with the ActiveScript languages (vbscript or jscript) because 

>    ActiveScriptEngine.call(Object object, String method, Object[] args)
>
>starts with object.toString()...

I now have it working, more or less (with SOAP 2.1). I replace the problem line

        Object result = eng.call (null, methodName, args);

with a hack... if we're about to fail, build an expr and eval it instead:
-----
       Object result;
       if(!(eng instanceof com.ibm.bsf.engines.activescript.ActiveScriptEngine))
         result=eng.call (null, methodName, args);
       else { 
         StringBuffer sb = new StringBuffer(300);
         sb.append(methodName).append("(");
         if (args != null && args.length > 0) {
         sb.append(args[0].toString());
         for(int i=1; i<args.length;i++)
           sb.append(",").append(args[i].toString());
         }
         sb.append (")");
         result=eng.eval("",0,0,sb.toString());
----
This works fine, at least on the samples/calculator example. Within the 
deployment descriptor I change script language to language="vbscript"
and the javascript code to, e.g.,
----
       Public Function plus(x,y)
         plus = x + y
       End Function
----
and similarly for the other functions. No further problem. Of course
further changes may be needed if we try to call vbscript or jscript
with more complex arguments, but I would think it's better to have
a simple working example than none.

Tom Myers http://www.n-topus.com


---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org


Re: InvokeBSF with ActiveScriptEngine...bug workaround/fix?

Posted by Tom Myers <to...@dreamscape.com>.
As I said at 07:13 PM 4/25/2001 -0400,

>The org.apache.soap.server.InvokeBSF.service(..) method uses
> >       BSFManager mgr = (BSFManager) target;
> >       BSFEngine eng = mgr.loadScriptingEngine (dd.getScriptLanguage ());
> >       Object result = eng.call (null, methodName, args);
>
>which works just fine on Rhino javascript, e.g. the Calculator example; but
it blows up with the ActiveScript languages (vbscript or jscript) because 

>    ActiveScriptEngine.call(Object object, String method, Object[] args)
>
>starts with object.toString()...

I now have it working, more or less (with SOAP 2.1). I replace the problem line

        Object result = eng.call (null, methodName, args);

with a hack... if we're about to fail, build an expr and eval it instead:
-----
       Object result;
       if(!(eng instanceof com.ibm.bsf.engines.activescript.ActiveScriptEngine))
         result=eng.call (null, methodName, args);
       else { 
         StringBuffer sb = new StringBuffer(300);
         sb.append(methodName).append("(");
         if (args != null && args.length > 0) {
         sb.append(args[0].toString());
         for(int i=1; i<args.length;i++)
           sb.append(",").append(args[i].toString());
         }
         sb.append (")");
         result=eng.eval("",0,0,sb.toString());
----
This works fine, at least on the samples/calculator example. Within the 
deployment descriptor I change script language to language="vbscript"
and the javascript code to, e.g.,
----
       Public Function plus(x,y)
         plus = x + y
       End Function
----
and similarly for the other functions. No further problem. Of course
further changes may be needed if we try to call vbscript or jscript
with more complex arguments, but I would think it's better to have
a simple working example than none.

Tom Myers http://www.n-topus.com


---------------------------------------------------------------------
To unsubscribe, e-mail: soap-user-unsubscribe@xml.apache.org
For additional commands, email: soap-user-help@xml.apache.org