Freitag, 1. Februar 2008

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

1 Kommentar:

Nasir Khan hat gesagt…

Peter, impressive blog. I would like to draw your attention towards a open source SIP application testing framework SIPr called Sipper. http://www.voip-info.org/wiki/view/Sipper or http://sipr.agnity.com. Your comment and impression will be most valuable. Thanks