Posts mit dem Label b2bua werden angezeigt. Alle Posts anzeigen
Posts mit dem Label b2bua werden angezeigt. Alle Posts anzeigen

Freitag, 1. Februar 2008

Create a SIP Application for Sailfin (Part 3 Webapp)

The third and last part shows how to build a simple web based administration for the user database with basic create, read, update and delete functionality. The application is modeled after the sample in http://www.netbeans.org/kb/60/web/inserts-updates-deletes.html.

View the Data
  1. Create the web page with "New->Visual Web JSF Page" and a session bean with
    "New->Visual Web JSF Session Bean".
  2. Open the visual web page editor for the created page. Then go to the "Services" tab, connect to the database and select the USERDATA table. Drag and drop it to the editor's canvas. You will see in the navigator window that a Data Provider object and a Row Set object were created.
  3. Drag and drop a table on the canvas. Select the table, right click and select "Bind to Data". Choose the userdataDataProvider which was created before and click OK. The table is now able to display data for users.
  4. Deploy the application and point your browser to localhost:8080/b2bua to view the contents of USERDATA.

Create and Delete

  1. Add a button "Add User" and a button "Save Changes".
  2. Doubleclick the "Add User" button and enter the action code from the sources.
  3. Doubleclick the "Save Changes" button and enter the action code from the sources.
  4. Select the table and open the layout editor. Add a new column and change the type of the column to "Button".
  5. Doubleclick the "Delete" button and enter the action code from the sources.
  6. Deploy the application again. You can now create and delete user data. The changes are stored in the database when you click "Save Changes".

Create a SIP Application for Sailfin (Part 2 Servlets)

In this part we will add a Sip Servlet for registration (handling the REGISTER message and storing the users contact information in the database) and a Sip Servlet which acts as a B2B User Agent transparently routing between A and B party.

Create Servlets
  1. Create a new class ModelFacade in the sip.model package. This class contains the methods UserData findUserDataById(String userId) and UserData updateUserData(UserData user) which are used by the Registration Servlet.
  2. Create a RegisterSipServlet class and a B2BUASipServlet class with "New->Sip Servlet".
  3. The code for both you can copy from provided sources.
  4. In configuration files add the RegisterSipServlet and the B2BUASipServlet to sip.xml and the ModelFacade to web.xml.
  5. Deploy the application.

Prerequisites for Testing

  1. Get a softphone (e.g. X-Lite from http://www.counterpath.com/) and configure its settings (e.g. username to "Bob", domain to "test.com", proxy to localhost:5060).
  2. If you are running the second softphone on the same machine you need a different model as second phone (e.g. 3CX VOIP phone from http://www.3cx.de/voip-telefon/index.html) and configure it for a second user (e.g. Alice)

Test the Application

  1. Start both softphones, on X-Lite you should see "Ready, your username is Bob" on the display
  2. Dial from A party as sip:user@siphost:port, e.g. sip:Alice@localhost:5057
  3. The second phone rings and you can start the conversation
  4. When you go onhook the call is terminated.

Automatic Testing with SIPp tool

  1. Download the SIPp tool from http://sipp.sourceforge.net/. On Windows you also have to download WinPCap from http://www.winpcap.org/devel.htm
  2. Run a basic test with ant -f tests.xml tc-001-basic-ua

Donnerstag, 31. Januar 2008

Create a SIP Application for Sailfin (Part 1 Database)

I will go step by step through creating a simple SIP application using the NetBeans IDE for the Sailfin Sip application server. In part 1 we will setup the user database where the Sip users will register themselves.

Prerequisites
  1. get the NetBeans IDE from http://www.netbeans.org/community/releases/60/index.html and the NetBeans Sip application development from https://sailfin.dev.java.net/servlets/ProjectDocumentList (in the appdevnb section).
  2. follow the installation instructions in http://blogs.sun.com/nb_sip_sailfin_installation/resource/nb_sip_sailfin_installation.html
  3. The sources are available in cvs using
    cvs -d:pserver:[your java.net account]@cvs.dev.java.net:/cvs co sailfin/sailfin-tests and then can be found then in community/samples/b2bua, or send an email to
    peter.c.klein@siemens.com to get them.

Preparing the database:

  1. Open the database settings in NetBeans with "Tools->Java DB Database->Settings" and select your Java DB installation (normally in sailfin/javadb) and the database location (normally in sailfin/databases).
  2. Start the DB server with "Tools->Java DB Database->Start Server".
  3. Create a new database with "Tools->Java DB Database->Create Database", then enter the database name (b2bua), the username (APP) and password (APP).
  4. You can then connect to the database from the Servers tab. Click on the database connection, right click and then Connect.

The application itself is a simple Sip back-to-back user agent which allows to build up a communication between two Sip phones and acts as a Registrar which handles the registration of the Sip users.


Creating the Data Storage

  1. Create a new project with "File->New Project" and choose Sip and Converged Servlet Application as project type. The project name of our sample is b2bua.
  2. In the project view select Source Packages, right click and choose "New->Sip Servlet", enter RegisterSipServlet as class name and b2bua.sip as package name.
  3. In the project view select Source Packages, right click and choose "New->Entity Class", enter UserData as class name and b2bua.model as package name. In the same dialog box click on "Create Persistence Unit".
  4. Choose "New Data Source" and in the next dialog box set jdbc/b2bua as JNDI name and select the prevously created database connection to b2bua.
  5. Look at the downloaded source code for UserData.java. You will see that the attribute sipURI and its getter and setter methods were added. In sipURI the URI of the registered user is stored.

Deployment of Part 1

  1. Open the projects properties, go to the "Run" page, select Java System Application Server as server and uncheck the "Display Browser on Run" checkbox.
  2. Select "Run->Run Main Project" to deploy the application. Depending on the sailfin version you are using there might be some warnings during deployment. Important is the output line "Enable of b2bua in target server completed successfully".
  3. Check the deployment on the sailfin admin console. Point your browser to http://localhost:4848/ and check "Applications->Sip->Converged Sip Modules" entries. b2bua should be visible as deployed.
  4. Connect to the database, open the USERDATA table, right click and select "View Data". The table should be empty. Add data by entering "insert into USERDATA values ('Bob@test.com', ''); in the SQL window, right click and select "Run Statement".
  5. You can also another SQl client, e.q Squirrel (download from http://squirrel-sql.sourceforge.net/, good instructions can be found in http://db.apache.org/derby/integrate/SQuirreL_Derby.html). Squirrel allows to directly modify the database without using SQL statements