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/28 22:58:02 UTC
Re: InvokeBSF with ActiveScriptEngine...bug workaround/fix?
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