JsonBridge

  • rss
  • archive
  • JsonBridge on Facebook

    You can find now JsonBridge on Facebook by visiting http://www.facebook.com/jsonbridge Code samples, downloads notifications and other related news will be posted on http://jsonbridge.com and Facebook both now.

    • 3 months ago
    • #JustMigrate
  • JsonBridge client for ActionScript 3

    JsonBridge client for ActionScript 3 got updated, Grab it from http://svn.skitsanos.com:8888/svn/sas3lib/ with demo/demo as your SVN credentials.
    Today’s changes in ActionScript client is about latest support of JBAPs (JsonBridge Authentication Plugins) where you can use your own Authorization HTTP header to handle authentication.

    Just to get you an very basic idea on how to use this thing in your Flex or ActionScript 3 application, here is the code sample for you, but let’s define our JsonBridge end-point URL:
    private var urlJsonBridge:String = ‘http://jsonbridge.mywdk.com/jsonbridge/’;

    Because we enabled JBAP in our web.config which look like this now:
    <?xml version=”1.0”?>
    <configuration>
      <appSettings>
        <add key=”jsonbridge.AuthEnabled” value=”true”/>
      </appSettings>
      <system.web>
        <compilation debug=”true” targetFramework=”4.0”/>
      </system.web>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests=”true”/>
      </system.webServer>
    </configuration>

    we need to tell JsonBridge to use Authorization and pass to it new Authorization HTTP Header:
    JsonBridge.url = urlJsonBridge;
    JsonBridge.useAuthorization = true;
    JsonBridge.authorizationHeader = new URLRequestHeader(‘Authorization’, ‘Simple demo:demo’);

    And now we can perform the call to server side methods, for example we want to browse available server side assemblies:
    JsonBridge.execute(‘_browse’, null, null, function (success:Object):void
    {
    textOutput.text = ”;
    if (success.type == “error”)
    {
    textOutput.text = success.message;
    } else
    {
    for (var i:int = 0, l:int = success.result.length; i < l; i++)
    {
    textOutput.text += (success.result[i] + ‘\n’);
    }
    }
    }, function (failure:Object):void
    {
    textOutput.text = failure.message;
    });

    As you can see execute() method didn’t changed at all, so all your old applications can function with no changes required.

    sas3lib.swc Download this file
    JsonBridgeExample.zip Download this file
    • 8 months ago
    • #JustMigrate
  • JBAP: JsonBridge and Authentication plugins

    We just released new JsonBridge updates for .NET that finally allows you to have very flexible way of handling authentication for your REST requests. This way you can implement Basic Authentication or support for OAuth or any other type of Authorization you would like to have for your own web application. To enable JBAP (JsonBridge Authentication Plugin) you need to make sure your web.config has jsonbridge.AuthEnabled set to true, otherwise JsonBridge will ignore your Authorization header and continue executing your request in free mode.
    web.config
      <appSettings>
        <add key=”jsonbridge.AuthEnabled” value=”true”/>
      </appSettings>

    Then you need to write your own JBAP/plugin, which is pretty straight forward thing, you just need to make sure you keep the class path like JBAP.YourAuthenticationClassName so when JsonBridge with jsonbridge.AuthEnabled set to true will execute request it will look into HTTP header Authorization find the name of the Handler and will try to load JBAP.YourAuthenticationClassName.dll in order to execute validate method. Validate method accepts just one parameter.
    So if your HTTP header looks like this:
    Authorization: Simple demo:demo

    JsonBridge will look for JBAP.Simple.dll invoke validate method and pass to it everything that goes after Simple, in my particular example it will receive demo:demo
    If validate method will return false you will see “Authorization failed” error wrapped into JsonBridge reply of InvokationErrorType type. Otherwise, on true it will execute your request and return you result you expect from your invoked method.

    Example of JsonBridge Authentication Plugin (JBAP)
    namespace JBAP
    {
    public class Simple
    {
    public bool validate (string authHeaderValue)
    {
    var authPair = authHeaderValue.Split (‘:’);
    if (authPair [0] == authPair [1])
    {
    return true;
    }
    else
    {
    return false;
    }
    }
    }
    }}

    JsonBridge is available as Open Source contribution and you can grab it from our WDK10 SVN here:
    http://skitsanoswdk.googlecode.com/svn/trunk/WDK10/ 
    For developers that using Java instead .NET we ill provide access to Java sources a bit later these days. Older version you can grab from our labs SVN: http://svn.skitsanos.com:8888/svn/JsonBridge/java

    • 9 months ago
    • #JustMigrate
  • jQuery client is onboard

    jQuery client is ‘preloaded’ with JsonBridge, you can access it on your web application/site via simply typing http://yoursitename/jsonbridge/jquery.jsonbridge.js, you can see it as an example on http://jsonbridge.mywdk.com/jsonbridge/jquery.jsonbridge.js, you can also directly include it same way into your html like:

    <script type=”text/javascript” src=”http://jsonbridge.mywdk.com/jsonbridge/jquery.jsonbridge.js” ></script>

    • 2 years ago
    • #JustMigrate
    • #javascript
    • #tips
  • ActionScript 3 client for JsonBridge

    We are glad to anounce that ActionScript 3 client for JsonBridge available as well and now it’s a part of sas3lib (available via SVN from http://labs.skitsanos.com:8888/svn/sas3lib). JsonBridge client available in com.skitsanos.net.remoting package of sas3lib.

    It has jut one method: execute() which accepts following parameters:

    • classpath:String, 
    • method:String, 
    • params:Array, 
    • resultHandler:Function, 
    • faultHandler:Function

    Example on how to use it:

    var params:Array = [{location: 23, dateTo: ‘01/01/2011’, dateFrom: ‘03/18/2011’}];

    var jb:JsonBridge = new JsonBridge();

    jb.url = ‘http://mywebsite/jsonbridge/’;

    jb.execute(‘Reporting.ReceivedVolumeReport’, ‘getTotalsForPackagingItems’, params, function(e:Object):void

    {
        trace(e.toString());
    }, function(e:Object):void

    {
        trace(e.message);
    });

    • 2 years ago
    • #JustMigrate
    • #.net
    • #actionscript
    • #flex
  • JSON Bridge for Remote Method Invocation

    Just wanted to share couple of notes on what’s cooking wond here at Skitsanos Labs… Recently i was banging my head into a wall on where to find some simple and effective way to call remote methods on server side and return back results to my application written in JavaScript and in Adobe Flex. There are quite many frameworks that allows you to do RPC or Remoting, but none of them actually was simple enugh to jump start any application with minimal effort, and we had in mind at least following list if requirements:

    • We should keep existing business logic as is, with no modifications to existing classes and methods;
    • We need access to server side classes and their methods via RESTful interface and provide output in atleast JSON format;
    • Keeping in mind that we are going ‘mobile’ on some projects, we need to make sure that there won’t be any need to implement any new functionality to cover mobile clients;
    • We need it workign from any programing language, but first ones to test against were JavaScript (with jQuery) and Adobe Flex/Aswing/ActionScript 3
    • We need support for service methods like browse list of server side assemblies, list their classes and methods.
    • We need to keep and reuse existing functionality provided by web server*.
    • We need to have support for ‘simple’ and ‘complex’ class method parameters both.

    So, last 2 days i spend on making JsonBridge that goes to be part of next WDK10 (set of in house libraries we use in all projects, mainly made for modular content management engine). As result I have simple solution, that we can use in all projects we are working on. JsonBridge works with GET and POST methods, calls that require any method parameters, can be called with GET, calls that require some parameters sent should be done via POST.

    Example of the method that can be called via GET:

    public string execute()
    {

    return “WDK.API.JsonBridge.Text.execute() works!”;
    }

    I can call this method like this:

    http://jsonbridge.vpn/jsonbridge/WDK.API.JsonBridge.Test/execute

    Where:

    • WDK.API.JsonBridge.Test is the Class path 
    • execute - is the method within this class

    Example of the method that requires POST:

    public string executeWithComplexParam(string param, TestParamType param2)
    {

    return “Your param: ” + param + ” and param2.name: ” + param2.name + “, param2.status: ” + param2.status.ToString();
    }

    As you can see it has 2 parameters, one ‘simple’ and one ‘complex’ type, to invoke this method on server i just need to call URL like this:

    http://jsonbridge.vpn/jsonbridge/WDK.API.JsonBridge.Test/executeWithComplexParam

    and post in request body JSON array of parameters:

    [
    “my first parameter”, 
    {“name”: “zz”, “status”: “200”}
    ]

    JsonBridge will analize number of parameters you sent, their types and so on and when everything meets invocation criteria it will call/invoke server side method and return you result.

    Like this in my case:

    Your param: my first parameter and param2.name: zz, param2.status: 200

    Basically that’s it.

    You can see it in action at this simple demo: http://jsonbridge.mywdk.com/

    • 2 years ago
    • #JustMigrate
    • #.net
    • #tips
© 2013 JsonBridge