A small demo: BeepBeep in 5 minutes

You might also want to look at slides for a presentation about BeepBeep given at the 21st Computer Aided Verification conference (June 2009).

Consider a library which makes its catalog available online through a web service interface. You built a small AJAX client that allows a user to:

This application sends and receives XML messages, as specified by the library, through the Javascript XMLHttpHeader class provided by the client's browser (or MSXML in the case of Internet Explorer). This is shown in the left part of the figure below.

Normal vs. BeepBeep comunication with a web service

Service interface contract

However, the library imposes constraints on the actual "conversation" your client can actually have with its service. These constraints can be found in the WSDL document defining the service, or even in plain English in the documentation accompanying the service. For example:

  1. The time elapsed between the first two messages must be less than 5 seconds
  2. There can be an unlimited number of "return" and "borrow" messages, but all "return" messages must precede all "borrow" messages
  3. A book that is borrowed cannot be borrowed again until is has been returned

We could imagine other constraints. All these specifications form a kind of "contract" that any client application must fulfill. As an example, Google and Amazon provide contract rules in some form or another for the services they provide.

Using BeepBeep

BeepBeep allows you to monitor the exchange of messages between your client application and the web service. It sits in the client's browser, between your application and the outside world, as is shown in the right part of the previous figure.

One part of BeepBeep is a Javascript file providing a class called XMLHttpRequestBB, which behaves exactly like the standard XMLHttpRequest, with the exception that incoming and outgoing messages, before being actually sent (or returned), are analysed and possibly blocked if violations are found.

The other part is a small Java applet called BeepBeepMonitor. This applet is reponsible for actually analysing the incoming and outgoing messages with respect to the "contract", and signaling eventual errors back to the Javascript code.

Adding BeepBeep to your application

Adding BeepBeep to your AJAX application can be done in four steps:

1. Host BeepBeep. BeepBeep uses two files, beepbeep.js and beepbeep.jar. Host these two files with your AJAX application, together in the same directory.

2. Specify the contract. What BeepBeep checks depends on the actual contract you wish to enforce. BeepBeep looks for a file called beepbeep-contract.txt in the same directory it is hosted. Otherwise, you can specify the location yourself by editing the first line of beepbeep.js. See how to specify a contract.

3. Load BeepBeep. In your AJAX Javascript code, make sure beepbeep.jar is loaded by adding this line of code in the <head> portion of the HTML:

<script type="text/javascript" href="beepbeep.jar"/>

4. Call BeepBeep. Replace instantiations of XMLHttpRequest (or MSXML in Internet Explorer) with XMLHttpRequestBB. No other changes are required since XMLHttpRequestBB has exactly the same methods as the originals.

Back to the example

That's it! Here is BeepBeep in action on a simple AJAX client for the library example.

For more information

Main menu

SourceForge.net Logo