Dojo JSON-RPC + Java May 6th, 2008 at 12:01 am by Kris Zyp

Dojo supports JSON-RPC, which is an easy to use JSON-based remote method call format. JSON-RPC can be utilized for an interoperable approach to distributed computing and communicating with servers. We will look at an example of interacting with Java on the server and invoking a Java method from JavaScript using Dojo’s RPC services. We will be begin by demonstrating a simple JSON-RPC handler written in Java. First we will create a servlet and write a POST handler that will read the content from the request:

public class JsonRPC extends HttpServlet {
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
		throws ServletException, IOException {
         String content = streamToString(req.getInputStream());

(more…)

REST and RPC Relationship March 25th, 2008 at 1:58 pm by Kris Zyp

The Dojo Toolkit 1.1 (currently at RC2 stage) has introduced an improved RPC system that provides support for multiple forms of RPC like JSON-RPC and raw POST requests. The new RPC system also supports REST. Understanding the relationship between RPC and REST can help you to fully utilize this new system.

Often Representational State Transfer (REST) style architecture is pitted against Remote Procedure Call (RPC) style architecture. These contrasts may be beneficial for understanding the conceptual motivations and benefits of these two architectures. However, by understanding their relationship, RPC and REST style interaction can both be leveraged harmoniously. By utilizing the right combination of RPC and REST in the appropriate situations you can maximize application manageability, scalability, and efficiency. The relationship can be defined quite easily.

(more…)

Pluggable Web Services with SMD March 19th, 2008 at 7:11 am by Kris Zyp

We have been leading the efforts in the development of Service Mapping Description (SMD). SMD is a flexible format and can be used to describe JSON-RPC, REST, JSONP, and other web services. SMD will provide a foundation to facilitate a future of pluggable interoperable SAO-based web services, where client and server components can be decoupled. Existing client/server frameworks tend to have tightly coupled communication, and applications built with standalone JavaScript libraries like the Dojo Toolkit generally must build their own client and server communication with the only assistance in the form of Ajax wrappers. With SMD, web services can be described with an open format, and client libraries can utilize these SMD descriptions to build high-level friendly communication wrappers. Of course, the Dojo Toolkit has taken the lead with the new SMD implementations in the Dojo Toolkit 1.1, but with SMD-based web service interaction, there is no lock-in. This provides an open definition of web services: any client and server can participate in providing or consuming these web services.

(more…)

JSONPath Support March 17th, 2008 at 4:31 pm by Kris Zyp

We recently added JSONPath support to the Dojo Toolkit. In the Dojo Toolkit 1.1, JSONPath queries can now be executed by calling dojox.jsonPath.query. JSONPath is a powerful tool for extracting data from JavaScript data objects, and has query capabilities that are similar to those of XPath queries on XML, except applied to JSON originating data. JSONPath follows JavaScript/C syntax where possible, borrowing from ES4 and Python as needed for certain operations, making for a very readable portable syntax.

(more…)

Jaxer and the Dojo Toolkit’s DTL February 29th, 2008 at 1:22 pm by Kris Zyp

Using Dojo’s Django Template language on Jaxer

Aptana’s Jaxer is a server side JavaScript (SSJS) server. With some modifications to a web page, the Dojo Toolkit 1.1 will be able to run on the server. With the Dojo Toolkit running on the server, you can utilize the Dojo Toolkit’s Django Template library (DTL) rendering engine to do templating within Jaxer. The current build of the Dojo Toolkit does not yet include support for Jaxer, but support is currently being added and future builds should include patches to properly work with Jaxer. Once Jaxer support has been added to the Dojo Toolkit, the following modifications will be needed for your page to run on the Jaxer server:

(more…)