I'm not convinced my hunch was correct anymore, now that I've seen the
API... Rhino should already have been selecting the correct overloaded
method.  You should be able to verify that in your full stacktrace.

Assuming that's the case, I can't think of any other obvious problems.
I'd try looking through the full stacktrace and narrow down the exact
location of the ClassCastException, it may give you an idea of what is
trying to be casted to what unsuccessfully and help you narrow down the
issue.  It's possible that the problem is elsewhere in your code when
you're assembling the request object or something like that.

If you still can't get this working in JS you could try putting that
block of logic in a separate Java helper class method and just calling
that method with the appropriate input values; that should avoid the
issues arising from Rhino's runtime type resolution.  Or you could move
to JavaFlow if you'd rather go that way.

Good luck
--Jason


Andrew Madu wrote:
> Jason,
> 
>> If that's the case then I think you can use the technique described at
>>
>> the bottom of
>>
>> http://www.mozilla.org/js/liveconnect/lc3_method_overloading.html (the
>>
>> section "Explicit Method Specification") which should allow you to
>>
>> choose the specific overloaded method to use.
>>
> 
> i'm trying to implement the info you sent me but am having a bit of
> trouble with the syntax. The class in question reads as so:
> 
> public class CallerServices {
> 
> 
>     /**
>      * Initializes the API Caller 
>      * @throws PayPalException 
>     */
>     public void initialize() throws PayPalException
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>
> { 
>         caller
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>
> = APICallerFactory
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICallerFactory.source.html#-1822136301>.createAPICaller
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICallerFactory.source.html#-347892909>();
>  
>     }
> 
>     /**
> 
>      * Invokes an API call from a request object
> 
>      * @param operationName name of web service to invoke
> 
>      * @param request request object
> 
>      * @return response object
> 
>      * @throws PayPalException if no profile is set, or an error occurs
> while executing the call
> 
>     */
> 
> *    **public** AbstractResponseType call(String operationName,
> AbstractRequestType request) **throws** **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>*
> {** *
> *        **if (**caller*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>*
> == null) {*
> **
> *            **this.**initialize*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1890163899>*();*
> *
> *
> *        **}** *
> *        **return** **caller*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-488948067>*.**call*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/core/APICaller.source.html#612444619>*(**operationName*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-1384803100>*,
> **request*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1844704353>*);**
>  *
> *    **}*
> 
>     
> 
>     /**
> 
>      * Invokes an API call from an XML request string (NOTE: Used only
> by the console) 
>      * @param operationName name of web service to invoke 
>      * @param requestStr request string
> 
>      * @return response string
>      * @throws PayPalException
> 
>     */
> *    **public** String call(String operationName, String requestStr)
> **throws** **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>*
> {*
> *
> *
> *        **AbstractRequestType request =
> (AbstractRequestType)**XMLSerializer*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#599806693>*.**fromXML*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#741945851>*(**requestStr*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-454823755>*);**
>  *
> *        **AbstractResponseType response = this.**call*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#1581845376>*(**operationName*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-344207329>*,
> **request*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#-819333156>*);*
> * *
> *        **return** **XMLSerializer*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#599806693>*.**toXML*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/util/XMLSerializer.source.html#-1525636627>*(**response*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/services/CallerServices.source.html#423409812>*);**
>  *
> *    **}** *
> }
> 
> The method I am after is:
> 
> * public AbstractResponseType call(String operationName,
> AbstractRequestType request) throws **PayPalException*
> <http://jsourcery.com/output/paypal/sdk/1.1/com/paypal/sdk/exceptions/PayPalException.source.html#1579179959>
> 
> So I do the following in my flowscript:
> 
> importClass(Packages.com.paypal.sdk.services.CallerServices);
> ....
> response = CallerServices["call(String, AbstractRequestType)"]; 
> response(5);
> 
> I am now getting the following error message:
> 
> *Java class "com.paypal.sdk.services.CallerServices" has no public
> instance field or method named "call(String, AbstractRequestType)".*
> *
> *
> What am I doing wrong here?
> 
> Andrew
> 
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to