The SIP Servlet Tutorial

The SipProxy Example

This example is a simple SIP proxy servlet. The proxy servlet will forward all SIP messages from the caller client to the callee server.

Developing the SIP Servlet

The SIP servlet is called SimpleProxyServlet, and extends the base SipServlet class and implements the SipErrorListener and Servlet interfaces.

public class SimpleProxyServlet 
            extends SipServlet 
            implements SipErrorListener,Servlet {
    /** Creates a new instance of SimpleProxyServlet */
    public SimpleProxyServlet() {
    protected void doInvite(SipServletRequest request) 
        	throws ServletException, IOException {
			if (request.isInitial()) {
				Proxy proxy = request.getProxy();
				proxy.proxyTo(request.getRequestURI()); // bobs uri
			System.out.println("SimpleProxyServlet: Got request:\n" + request);
    protected void doBye(SipServletRequest request) throws 
				ServletException, IOException {
        System.out.println("SimpleProxyServlet: Got BYE request:\n" + request);
    protected void doResponse(SipServletResponse response) 
        throws ServletException, IOException {
        System.out.println("SimpleProxyServlet: Got response:\n" + response);
    // SipErrorListener
    public void noAckReceived(SipErrorEvent ee) {
        System.out.println("SimpleProxyServlet: Error: noAckReceived.");
    public void noPrackReceived(SipErrorEvent ee) {
			System.out.println("SimpleProxyServlet: Error: noPrackReceived.");

SIP Methods

In SimpleProxyServlet, you override several methods to respond to the main SIP methods.

SipErrorListener Methods

Because SimpleProxyServlet implements the SipErrorListener interface, it must implement the following methods:

Deploying and Running SipProxy

Follow these instructions to deploy and run the example.

ProcedureDeploying and Running SipProxy in NetBeans IDE

  1. Click File->Open Project and navigate to the location where you downloaded and expanded the SimpeProxy example.

  2. Select SipProxy and click Open Project.

  3. Right-click on SipProxy in the Projects pane and click Run.

ProcedureTesting SipProxy with the SIPp Application

Before You Begin

Be sure you have installed the SIPp test application, as described in SIPp Test Application.

  1. In a terminal, enter the following command to start the SIPp server on port 5090:

    % sipp -sn uas -p 5090
  2. In a new terminal enter the following command to start the SIPp client on port 5080:

    % sipp -sn uac -rsa -p 5080

    You should now see the messages from the client get returned by the server, with the SipProxy application acting as a proxy between them.