Categories

Archives

JavaScript Client-Server Integration Crash Course

WebORB is very well known for its integration capabilities for Flex and Flash clients, but is is an equally powerful integration server for the JavaScript clients as well (both mobile and desktop). In the next series of posts I’d like to demonstrate how easy it is to build a JavaScript application and integrate it with the backend service using WebORB as the integration server. The application I am going to build and document via a series of blog posts is rather simple, but it is representative of a lot of use-cases developers run into when building enterprise or consumer apps. The application will demonstrate basic buy cialis online remote procedure calls (RPC) between JavaScript and Java/.NET, asynchronous calls, retrieving data from a database, updating/deleting/creating database records. Later on I will show how to build the same application using WebORB’s data management framework. Finally, I will delve into publish/subscribe messaging for the JavaScript clients and show how to use JavaScript WebSockets with the WebORB’s messaging APIs.

To start you will need to install the MySQL database server and execute the following script which creates a database used by the application:

<br />
-- MySQL Administrator dump 1.4<br />
--<br />
-- ------------------------------------------------------<br />
-- Server version	5.1.38</p>
<p>/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;<br />
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;<br />
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;<br />
/*!40101 SET NAMES utf8 */;</p>
<p>/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;<br />
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;<br />
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;</p>
<p>--<br />
-- Create schema phonebook<br />
--</p>
<p>CREATE DATABASE IF NOT EXISTS phonebook;<br />
USE phonebook;</p>
<p>--<br />
-- Definition of table `phonebook`.`Listing`<br />
--</p>
<p>DROP TABLE IF EXISTS `phonebook`.`Listing`;<br />
CREATE TABLE  `phonebook`.`Listing` (<br />
  `id` int(11) NOT NULL AUTO_INCREMENT,<br />
  `name` varchar(100) DEFAULT NULL,<br />
  `phonenumber` varchar(15) DEFAULT NULL,<br />
  PRIMARY KEY (`id`)<br />
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8;</p>
<p>

You can also download the script from: http://examples.themidnightcoders.com/blog/phonebook.sql

Once the database is created, it is important to create a database user with the username “phonebookuser” and the password set to “password”. Grant all the privileges to the “phonebook” schema to the “phonebookuser” user.

Once the database is setup, you will need to configure your development environment:

  1. Download and install WebORB
  2. Install an IDE. For Java developers we recommend IntelliJ IDEA (The Community Edition is free), but you can also use the Eclipse  IDE. For .NET developers, Visual Studio is your best option.

The next post will explore the server-side code. You will compile and deploy the backend service and try invoking the methods with the WebORB management console.