js/ServiceMethod.js
function (payload, plugins, ioArgs) {
                var writePayload = payload || "", intermediate, that = this;

                // Very simiplistic payload type coercion
                if (this.requestPayloadName && !payload[this.requestPayloadName]) {
                    payload = {};
                    payload[this.requestPayloadName] = writePayload;
                }

                // Allow request plugins to execute
                util.executePluginChain(plugins.request, function (plugin) {
                    intermediate = plugin.fn.call(plugin.scope || plugin, payload, that, ioArgs);
                    payload = intermediate || payload;
                });

                writePayload = (this.requestPayloadName && payload[this.requestPayloadName]) || payload;

                // Allow write plugins to execute
                util.executePluginChain(plugins.write, function (plugin) {
                    if (util.isArray(writePayload)) {
                        writePayload.forEach(function (item, idx) {
                            intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
                            writePayload[idx] = intermediate || writePayload[idx];
                        }, that);
                    } else {
                        intermediate = plugin.fn.call(plugin.scope || plugin, writePayload, that);
                        writePayload = intermediate || writePayload;
                    }
                });

                if (this.requestPayloadName) {
                    payload[this.requestPayloadName] = writePayload;
                } else {
                    payload = writePayload;
                }

                return payload;
            }
function (payload, plugins, ioArgs) {
                var writePayload = payload || "", intermediate, that = this;

                // Very simiplistic payload type coercion
                if (this.requestPayloadName && !payload[this.requestPayloadName]) {
                    payload = {};
                    payload[this.requestPayloadName] = writePayload;
                }

                // Allow request plugins to execute
                util.executePluginChain(plugins.request, function (plugin) {
                    intermediate = plugin.fn.call(plugin.scope || plugin, payload, that, ioArgs);
                    payload = intermediate || payload;
                });

                writePayload = (this.requestPayloadName && payload[this.requestPayloadName]) || payload;

                // Allow write plugins to execute
                util.executePluginChain(plugins.write, function (plugin) {
                    if (util.isArray(writePayload)) {
                        writePayload.forEach(function (item, idx) {
                            intermediate = plugin.fn.call(plugin.scope || plugin, item, that);
                            writePayload[idx] = intermediate || writePayload[idx];
                        }, that);
                    } else {
                        intermediate = plugin.fn.call(plugin.scope || plugin, writePayload, that);
                        writePayload = intermediate || writePayload;
                    }
                });

                if (this.requestPayloadName) {
                    payload[this.requestPayloadName] = writePayload;
                } else {
                    payload = writePayload;
                }

                return payload;
            }
function ( payload , plugins , ioArgs ) { var writePayload = payload || "" , intermediate , that = this ; // Very simiplistic payload type coercion
 if ( this . requestPayloadName && ! payload [ this . requestPayloadName ] ) { payload = { } ; payload [ this . requestPayloadName ] = writePayload ; } // Allow request plugins to execute
 util . executePluginChain ( plugins . request , function ( plugin ) { intermediate = plugin . fn . call ( plugin . scope || plugin , payload , that , ioArgs ) ; payload = intermediate || payload ; } ) ; writePayload = ( this . requestPayloadName && payload [ this . requestPayloadName ] ) || payload ; // Allow write plugins to execute
 util . executePluginChain ( plugins . write , function ( plugin ) { if ( util . isArray ( writePayload ) ) { writePayload . forEach ( function ( item , idx ) { intermediate = plugin . fn . call ( plugin . scope || plugin , item , that ) ; writePayload [ idx ] = intermediate || writePayload [ idx ] ; } , that ) ; } else { intermediate = plugin . fn . call ( plugin . scope || plugin , writePayload , that ) ; writePayload = intermediate || writePayload ; } } ) ; if ( this . requestPayloadName ) { payload [ this . requestPayloadName ] = writePayload ; } else { payload = writePayload ; } return payload ; }
An internal method used by invoke to massage and perform plugin processing on
a request payload. The method attempts to coerce the payload into the type specified
in the smd and then runs the 'request' and 'write' plugins returning the new payload.

@param {Object} payload - the request data passed to the service method by the client.
@returns {Object} newPayload - the new or modified payload.
An internal method used by invoke to massage and perform plugin processing on a request payload . The method attempts to coerce the payload into the type specified in the smd and then runs the request and write plugins returning the new payload .