.. title:: dojo.rpc.RpcService -- The Dojo Manual

Name
===============================================================================

dojo.rpc.RpcService - RPC Base class for JavaScript

Summary and Overview
===============================================================================

``dojo.rpc.JsonService`` provides JSON-RPC services using a SMD (Simple Method
Description) definition of the available interfaces to construct an object
whose methods return values from a remote function asynchronously.  

Usage
===============================================================================

::

    var remoted = new dojo.rpc.JsonService("/path/to/interfaces.smd");

    // "doFoo" is a remote method exposed by the interfaces.smd file
    // the creation of the service object creates a local stub that we can call
    // and have asynchronously responded to. Upon execution a DeferredRequest
    // Object is returned.  The user can attach callback and errback functions
    // to this object to deal with the results
    // last parameter, a callback function

    var deferred = remoted.doFoo("arg1", arg2);
    deferred.addCallback(myCallbackFunc);
    deferred.addErrback(myErrbackFunc);

           -or-

    remoted.doFoo("arg1", arg2).addCallback(myCallbackFunc)



    //This class is a base class only, it must be overridden to provide
    //specific functionality.

API Reference
===============================================================================

Classes
---------------------------------------

``JsonService(url)``:

    Implements the JSON-RPC service based on the RpcService class
    Initialization begins with a url pointing at a SMD file.

    ``url``:
        String. URL pointing to an SMD file;
    
    *Inherits from*:
        dojo.rpc.RpcService

    *return*:
        new object of type ``JsonService``

Properties
~~~~~~~~~~~~~

``lastSubmissionId``:

    int. Counter of submissions, increments by 1 with each 
    submission.

Methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``parseResults(object)``:

    Overrides the superclasses' parseResults function. Pulls
    the results out of the raw JSON-RPC result envelope and
    returns them to the caller.
 
    ``object``:
        Raw data returned from the asyncronous request

    *return*:
        Parsed results. 

``createRequest(method, parameters)``:

    Transforms the method, parameters, and the serviceUrl 
    into a JSON-RPC request envelope.

    *return*:
        String: JSON-RPC envelope.

``bind(method,parameters,deferredRequestHandler)``:

    Performs the actual transport functions of the JSON-RPC
    request.  The postContent is populated by ``createRequest``
    and the load is generated by ``resultCallback`` 

    *return*:
        nothing


Requires
===============================================================================

- `dojo.io.*`_
- `dojo.json`_
- `dojo.lang`_
- `dojo.rpc.RpcService`_

.. _`dojo.io.*`: 		io.html
.. _`dojo.json`:	json.html
.. _`dojo.lang`:	lang.html
.. _`dojo.rpc.RpcService`: RpcService.html

Provides
===============================================================================

dojo.rpc.JsonService
    Implements the JSON-RPC Service on Dojo.

To Do
===============================================================================

Lots. But that's always true.

About
===============================================================================

:Author: Dustin Machi
:Version: 0.1
:Copyright: Dojo Foundation, 2005
:Date: 2005/12/30

.. vim:ts=4:et:tw=80:shiftwidth=4:
