public/javascripts/inputex/js/rpc/inputex-rpc.js
function(serviceName, method) {
      
      if(this[method]){
			throw new Error("WARNING: "+ serviceName+ " already exists for service. Unable to generate function");
		}
		method.name = serviceName;
	
		var self = this;
		var func = function(data, opts) {
		   var envelope = rpc.Envelope[method.envelope || self._smd.envelope];
		   var callback = {
   	      success: function(o) {
               var results = envelope.deserialize(o);
      	      opts.success.call(opts.scope || self, results);
   	      },
   	      failure: function(o) {
   	         if(lang.isFunction(opts.failure) ) {
						var results = envelope.deserialize(o);
   	            opts.failure.call(opts.scope || self, results);
   	         }
   	      },
   	      scope: self
   	   };
   	   
   	   
   	   var params = {};
   	   if(self._smd.additionalParameters && lang.isArray(self._smd.parameters) ) {
   	      for(var i = 0 ; i < self._smd.parameters.length ; i++) {
   	         var p = self._smd.parameters[i];
   	         params[p.name] = p["default"];
   	      }
   	   }
   	   lang.augmentObject(params, data, true);
   	   
   	   var url = method.target || self._smd.target;
   	   var urlRegexp = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/i;
   	   if(!url.match(urlRegexp) && url != self._smd.target) {
   	      url = self._smd.target+url;
   	   }
   	   
	      if( !!this.smdUrl && !url.match(urlRegexp) ) {
   	      // URL is still relative !
   	      var a=this.smdUrl.split('/');
   	      a[a.length-1]="";
   	      url = a.join("/")+url;
   	   }
   	   
   	   
         var r = {
            target: url,
            callback: callback,
            data: params,
            origData: data,
            opts: opts,
            callbackParamName: method.callbackParamName || self._smd.callbackParamName,
            transport: method.transport || self._smd.transport
         };
   	   var serialized = envelope.serialize(self._smd, method, params);
         lang.augmentObject(r, serialized, true);
         
   	   rpc.Transport[r.transport].call(self, r ); 
		};
		
		func.name = serviceName;
		func.description = method.description;
		func._parameters = method.parameters;
		
		return func;
   }
function(serviceName, method) {
      
      if(this[method]){
			throw new Error("WARNING: "+ serviceName+ " already exists for service. Unable to generate function");
		}
		method.name = serviceName;
	
		var self = this;
		var func = function(data, opts) {
		   var envelope = rpc.Envelope[method.envelope || self._smd.envelope];
		   var callback = {
   	      success: function(o) {
               var results = envelope.deserialize(o);
      	      opts.success.call(opts.scope || self, results);
   	      },
   	      failure: function(o) {
   	         if(lang.isFunction(opts.failure) ) {
						var results = envelope.deserialize(o);
   	            opts.failure.call(opts.scope || self, results);
   	         }
   	      },
   	      scope: self
   	   };
   	   
   	   
   	   var params = {};
   	   if(self._smd.additionalParameters && lang.isArray(self._smd.parameters) ) {
   	      for(var i = 0 ; i < self._smd.parameters.length ; i++) {
   	         var p = self._smd.parameters[i];
   	         params[p.name] = p["default"];
   	      }
   	   }
   	   lang.augmentObject(params, data, true);
   	   
   	   var url = method.target || self._smd.target;
   	   var urlRegexp = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/i;
   	   if(!url.match(urlRegexp) && url != self._smd.target) {
   	      url = self._smd.target+url;
   	   }
   	   
	      if( !!this.smdUrl && !url.match(urlRegexp) ) {
   	      // URL is still relative !
   	      var a=this.smdUrl.split('/');
   	      a[a.length-1]="";
   	      url = a.join("/")+url;
   	   }
   	   
   	   
         var r = {
            target: url,
            callback: callback,
            data: params,
            origData: data,
            opts: opts,
            callbackParamName: method.callbackParamName || self._smd.callbackParamName,
            transport: method.transport || self._smd.transport
         };
   	   var serialized = envelope.serialize(self._smd, method, params);
         lang.augmentObject(r, serialized, true);
         
   	   rpc.Transport[r.transport].call(self, r ); 
		};
		
		func.name = serviceName;
		func.description = method.description;
		func._parameters = method.parameters;
		
		return func;
   }
function ( serviceName , method ) { if ( this [ method ] ) { throw new Error ( "WARNING: " + serviceName + " already exists for service. Unable to generate function" ) ; } method . name = serviceName ; var self = this ; var func = function ( data , opts ) { var envelope = rpc . Envelope [ method . envelope || self . _smd . envelope ] ; var callback = { success : function ( o ) { var results = envelope . deserialize ( o ) ; opts . success . call ( opts . scope || self , results ) ; } , failure : function ( o ) { if ( lang . isFunction ( opts . failure ) ) { var results = envelope . deserialize ( o ) ; opts . failure . call ( opts . scope || self , results ) ; } } , scope : self } ; var params = { } ; if ( self . _smd . additionalParameters && lang . isArray ( self . _smd . parameters ) ) { for ( var i = 0 ; i < self . _smd . parameters . length ; i ++ ) { var p = self . _smd . parameters [ i ] ; params [ p . name ] = p [ "default" ] ; } } lang . augmentObject ( params , data , true ) ; var url = method . target || self . _smd . target ; var urlRegexp = / ^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$ / i ; if ( ! url . match ( urlRegexp ) && url != self . _smd . target ) { url = self . _smd . target + url ; } if ( ! ! this . smdUrl && ! url . match ( urlRegexp ) ) { // URL is still relative ! var a = this . smdUrl . split ( '/' ) ; a [ a . length - 1 ] = "" ; url = a . join ( "/" ) + url ; } var r = { target : url , callback : callback , data : params , origData : data , opts : opts , callbackParamName : method . callbackParamName || self . _smd . callbackParamName , transport : method . transport || self . _smd . transport } ; var serialized = envelope . serialize ( self . _smd , method , params ) ; lang . augmentObject ( r , serialized , true ) ; rpc . Transport [ r . transport ] . call ( self , r ) ; } ; func . name = serviceName ; func . description = method . description ; func . _parameters = method . parameters ; return func ; }
Generate the function from a service definition
@method _generateService
@param {String} serviceName
@param {Method definition} method
Generate the function from a service definition