IMS Services Development Tutorial

Intro

This is the first article that I wrote in order to show how / services can be built using the Servlets technology.

, known as , is a signaling protocol that is used by next-generation applications in the telecom industry.
The articles will be based on Servlets technology and I will also provide some examples in order to have you test the functionality by yourself. The examples will be coded in Java, which provides a very good platform for building applications.

What do I need to move forward?
It’s actually pretty simple, there are not so many prerequisites for this tutorial. Let’s just name a few:

- first, you need an IDE to run the examples. I’m using Ericsson SDS which I find really useful.
- Servlet API Specs, available here.
- SIP Protocol knowledge.
- HTTP Servlets knowledge.
- 15 minutes to get to the end of this tutorial :-)

Servlets. What are they?

The Servlets are quite similar with HTTP Servlets. There are alot of good articles on the Internet talking about both and HTTP Servlets. You can just quickly google for them so you can have a good understanding on how a servlet works.

A servlet is an object that receives a request and after processing it generates a response to the initial request. When using HTTP, we can process GET or POST methods inside a servlet and generate HTTP specific response messages such as “200 OK” or “404 Not Found”.When it comes to , a servlet can receive a request and response at any time.
A servlet container is a specialized server that supports servlet execution. There is an open-source implementation of a Application Server that I recommend, called Sailfin, which allows a developer to mix Servlets and Java EE components.


OK, I got it. Let’s move on!

The great thing about the Servlets is that the developer should only focus on the high-level of the application, while the actual servlet technology is taking care of transactions,dialogs, message parsing or other protocol specific things. What does it mean ?
Well, I will show you how can you build a very simple Redirect server with only five lines of code.

So here’s what we need to do.
First, we will create a new servlet, called RedirectServlet that extends the SipServlet defauld implementation:


public class RedirectServlet extends SipServlet {}

Once this is build, the next thing to do is to create the servlet’s init() method like this:


public void init(ServletConfig config) throws ServletException {

super.init(config);
ServletContext context = config.getServletContext();
sipFactory = (SipFactory) context
.getAttribute(”javax.servlet..SipFactory”);

}

What does our Redirect Server do ? For each INVITE request that it receives, it will perform a database query (not included here) and it will answer back ith a 302 Moved Temporarily message containing a new “Contact” field. Check the below lines of code:


protected void doInvite(SipServletRequest req)
throws ServletException, IOException {

//it gets the MSISDN from the next string. :MSISDN@domain.com

String MSISDN = req.getRequestURI().toString().substring(req.getRequestURI().toString().indexOf(”:”)+1, req.getRequestURI().toString().indexOf(”@”));

//check the above parsing
System.out.println(”MSISDN=”+MSISDN);

//building the 302 Moved Temporarily
SipServletResponse resp = req.createResponse(302);
resp.removeHeader(”Contact”);
// database_query(MSISDN) will return a new number to be put in the Contact field
resp.addHeader(”Contact”, database_query(MSISDN)+”@otherdomain.com”);
resp.send();

}

There you go! A brand new Redirect Server built in just 10 minutes.

To test the RedirectServlet, you need to use Ericsson’s SDS IDE and start a new project. The IDE has a Application Server built-in so you can easily test your new servlet inside the IDE. I will upload the complete source-code of the RedirectServlet in the next coming days.

I hope this article gives you a quick start on programming applications using Servlets technology. Once I’ll get some spare time, I will be happy o add some more articles related to this new technology.

Interested in other articles? Read my techLog here

Bookmarks: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netscape
  • Technorati
  • YahooMyWeb
  • Furl
  • Slashdot

Related posts

4 Responses to “IMS Services Development Tutorial”


  1. 1 mugur

    te plateste ericsson pentru asta?

  2. 2 Mihnea Teodorescu

    faptul ca apare numele ericsson acolo nu inseamna ca e reclama :-)

  3. 3 Tony

    Very good article, thank you!

  4. 4 adi

    nu ma asteptam sa gasesc informatii asa pretioase atat de aproape :))

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word