Custom JavaScript object wrapping SOAP calls

"xxx" <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Hi.  I'm writing some javascript object wrappers so that I can use either 
Mozilla or IE (and its webservice behavior) with my existing app to access 
some web services from the browser.  In particular, I'm dealing with 
asynchronous invocation.  I can successfully call the remote method, but I'm 
having trouble designing a good generic callback mechanism, since the 
argument lists are different between the Mozilla way and the IE 
webservice.htc way.

I'd like to do something like this...

var mycall = new MyCallWrapper("RemoteMethodName", myparamarray);
mycall.execute(mycallback);

...and have mycallback be called on return of the remote method.  Here's the 
idea of the MyCallWrapper class...

function MyCallWrapper(methodname, parameters) {
    this.method = methodname;
    this.params = parameters;
    this.call = new SOAPCall();
    // set info on the call object...
}
MyCallWrapper.prototype.execute = function (callback) {
    this.callback = callback;
    this.call.asyncInvoke(this.genericCallback);
}
MyCallWrapper.prototype.genericCallback = function (response, call, error) {
    // manip results into compatible forms between IE and Mozilla, then..
    this.callback(genericresponse, genericerror);
}

...but this doesn't work.  My genericCallback gets called after I run 
mycall.execute(), but then this.callback is always undefined.  I guess I'm 
not really getting the genericCallback called on the same instance of 
MyCallWrapper as I invoked the method on.  I think this is weird, but I'm 
not a javascript expert.  How can I get my generic callback function to call 
my "real" callback function?

Also, if a different model would be more appropriate, I'm open to 
suggestions!


thanks,
Chris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.