Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Server Data Binding with .net

    I'm new to Smartclient and so far I love it. The only problem is that I use .net on the back end. With other libraries, I've been using a library called Jayrock to Javascript RPC calls (http://jayrock.berlios.de/). All that is required is that special request headers be added:

    'X-JSON-RPC' = 'MethodToUseOnServer'
    and 'Content-type' = 'text/plain; charset=utf-8'

    All responses are of a set format following the RFCs for RPC calls and the library (de)serializes to/from json.

    With minor modifications, I could probably get smartclient to use services using jayrock on the backend. Is there any documentation as to the actual formats of calls to the server and returned data formats? Otherwise, I could probably look through the Java code (if available) and come up with an equivalent in c# or vb.net and modify the Jayrock library to work. Otherwise, I would just need a map of how the calls are put together (request headers, method name location in the request, (de)serialize formats, etc).

    For example: For paging (live grid binding), the requests must have some standard format:

    offset=200&per_page=50&data=fooBar
    the request header something like:

    RPC-METHOD = 'livegrid1pager'

    of course, if the method requires more data, it may use the POST method, etc...


    Please let me know if Isomorphic would like the code when I have it working. It may be an easy way to provide .net support for Smartclient data binding.


    Thanks,

    Paul Perrick

    #2
    Hi Paul,

    Integrating with something like Jayrock is called client-side data integration. The general idea is that SmartClient provides a DSRequest (DataSource Request) JavaScript object, then gives you the ability to customize how SmartClient will send an HTTP request to the server by implementing transformRequest. So transformRequest() is your opportunity to take abstract properties of the DSRequest, like DSRequest.startRow, and put them into the HTTP request in the format that your server is expecting.

    Likewise for responses, in transformResponse you are given access to the raw HTTP response (as an RPCResponse object) and expected to fill out a DSResponse (DataSource Response) object.

    Here is starter code for Jayrock that demonstrates how you can set the HTTP headers and URL params that Jayrock expects based on the DSRequest:

    Code:
    isc.defineClass("JRockDataSource", "DataSource").addProperties({
        dataFormat:"json",
        dataURL:"SomeDataURL",
        
        transformRequest : function (request) {
            // Set the required contentType - only has an effect for POST type requests
            // Note use request.httpMethod to specify POST or GET 
            request.contentType = "text/plain; charset=utf-8";
            
            
            if (!request.httpHeaders) request.httpHeaders = {};
            request.httpHeaders["X-JSON-RPC"] = this.jsonRPCMethod;
            
            // Example of setting "RPC-METHOD" based on operation type
            if (request.operationType == "fetch") request.httpHeaders["RPC-METHOD"] = "fetchData";
    
            // Set up the params to pass to the server
            var serverParams = request.params || {};
                
            // for jayrock, 'dsRequest.startRow' maps to 'offset', etc
            serverParams.offset = request.startRow;
            serverParams.per_page = request.endRow - request.startRow;
            serverParams.data = request.data;
            
            return serverParams;
        }
    });
    And yes, when you flesh this out, Isomorphic and other forum readers would almost certainly be interested in the final code. We could include in it future versions of the SmartClient SDK.

    Final note: the other major approach for .NET integration is to use WSDL binding to web services generated by Visual Studio, and the 5.7 SDK includes some (new) examples which extend popular .NET web service tutorials by adding SmartClient interfaces.

    Comment


      #3
      great

      Thanks for the example, do you have a timeframe for the 5.7 WSDL updates?

      Comment


        #4
        5.7 is already out - the .NET WSDL examples can be found in the isomorphicSDK/examples/databinding/dotNET folder.

        Comment


          #5
          Hi,
          i am using .net as well so far i am able to insert new rows and fetch data with a ListGrid and still have to fix delete and update operation.
          but was thinking since i saw many posts about smartclient usage with .net why no share information over an irc channel (something like: #smartclient on freenode) that way we can help each other and it would be faster for all of us to fix problems
          regards

          Comment

          Working...
          X