dojox.rpc.Service._executeMethod
dojo.require("dojox.rpc.Service");
defined in dojox/rpc/Service.js
Usage
function (method) (view source)
var args = []; var i; for (i=1; i< arguments.length; i++){ args.push(arguments[i]); } var smd = this._smd; if (method.parameters && method.parameters[0] && method.parameters[0].name && (args.length==1) && dojo.isObject(args[0])){ // if it is the parameters are not named in the definition, then we should use ordered params, otherwise try to determine by parameters args = args[0]; // inherit root-level parameters if (smd.parameters && smd.parameters[0]){ for (i=0; i< smd.parameters.length; i++){ if (smd.parameters[i]["name"] && smd.parameters[i]["default"]){ args[smd.parameters[i]["name"]] = smd.parameters[i]["default"]; } } } } if (dojo.isObject(this._options)){ args = dojo.mixin(args, this._options); } var envelope = method.envelope || smd.envelope || "NONE"; var envDef = dojox.rpc.envelopeRegistry.match(envelope); var schema = method._schema || method.returns; // serialize with the right schema for the context; var request = envDef.serialize.apply(this, [smd, method, args]); var contentType = (method.contentType || smd.contentType || request.contentType); var isJson = (contentType + '').match(/application\/json/); // this allows to mandate synchronous behavior from elsewhere when necessary, this may need to be changed to be one-shot in FF3 new sync handling model dojo.mixin(request,{sync : dojox.rpc._sync, handleAs : isJson ? "json" : "text", contentType : contentType, target : request.target || dojox.rpc.getTarget(smd, method), transport: method.transport || smd.transport || request.transport, envelope: method.envelope || smd.envelope || request.envelope, timeout: method.timeout || smd.timeout, callbackParamName: method.callbackParamName || smd.callbackParamName, preventCache: method.preventCache || smd.preventCache}); var deferred = (method.restMethod || dojox.rpc.transportRegistry.match(request.transport).fire).call(this,request); deferred.addBoth(dojo.hitch(this,function(results){ // if it is an application/json content type, than it should be handled as json // we have to do conversion here instead of in XHR so that we can set the currentSchema before running it results = envDef.deserialize.call(this,isJson ? dojox.rpc.resolveJson(results,schema) : results); return results; })); return deferred;
parameter | type | description |
---|---|---|
method |