Skip navigation.

Developing SIP Servlets with WebLogic SIP Server

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

Composing SIP Applications

The following sections describe how to use WebLogic SIP Server 2.1 application composition features:

 


Overview of SIP Application Composition

Application composition is the process of "chaining" multiple SIP applications, such as Proxies, User Agent Servers (UAS), User Agent Clients (UAC), redirect servers, and Back-to-Back User Agents (B2BUA), into a logical path that processes a given SIP request. WebLogic SIP Server provides support for an application composition model that enables applications to create and maintain a logical composition of multiple SIP applications. By using this programming model, you can easily define an order list of applications that should process a given initial SIP request, and the WebLogic SIP Server container ensures that each application remains on the call path for all subsequent requests.

 


Application Composition Model

The basic WebLogic SIP Server application composition model involves creating a main "composer" application that examines initial SIP requests to determine which deployed applications should process the request, and in what order. (For example, a composer application may examine the user specified in the Request-URI header and select applications based on the user's subscription level.) The composer application then inserts one or more Route headers into the request, with each Route header specifying the name and location of a deployed SIP application that should process the request. Application names are defined similar to user addresses, using the format:

application@address

where application is the deployment name of the SIP application and address is the address of the load balancer used to contact the WebLogic SIP Server installation, the cluster address, or the listen address of the server itself (for example, proxyapp1@mycompany.com). The order of the Route headers in the message dictate the required order of application execution. The Request-URI header of the initial request should remain unchanged.

After inserting Route headers to chain the required applications, the composer application then calls proxyTo() to proxy the message using the original Request-URI. The WebLogic SIP Server container examines the contents of the initial Route header in the request to determine if the user portion of the address refers to an application name. If the user name matches a deployed application name and the address matches a configured server address, then the server ignores any configured Servlet mapping rules and instead delivers the request to the named application.

Figure 3-1 Composed Application Model

Composed Application Model


 

After processing a request, applications that are part of a composed application path should remove the first Route header and proxyTo() the original Request-URI so that WebLogic SIP Server can direct the request to any additional applications specified in Route headers.

In this manner, WebLogic SIP Server honors the configured chain of applications that were defined by the composer application using Route headers. Figure 3-1 shows a summary of the application composition model.

Managing Proxied Requests

In addition to chaining applications for an initial SIP request, WebLogic SIP Server preserves the composed application chain for subsequent requests proxied to other servers. If a request is proxied to another server, the SIP Servlet container inserts the session IDs of chained applications into the Record-Route header of the message. WebLogic SIP Server examines the session IDs to ensure that each server hosting a chained application remains in the call path for subsequent requests.

 


Sample Composer Application

Listing 3-1 shows the organization of a simple composer application.

Listing 3-1 Sample Composer Application

package example;
import javax.servlet.sip.SipFactory;
import javax.servlet.sip.SipServletRequest;
import javax.servlet.sip.SipURI;
import javax.servlet.sip.SipServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import java.io.IOException;
public class Composer extends SipServlet {
  private SipFactory factory;
  private static final String CLUSTER_ADDRESS = "example.com";
  public void init(ServletConfig sc) throws ServletException {
    super.init(sc);
    factory = (SipFactory)
      getServletContext().getAttribute("javax.servlet.sip.SipFactory");
  }
  protected void doRequest(SipServletRequest req)
    throws ServletException, IOException {
    if (!req.isInitial()) {
      super.doRequest(req);
      return;
    }
    SipURI[] routeSet = getRouteSet(req);
    for (int i = 0; i < routeSet.length; i++) {
      req.pushRoute(routeSet[i]);
    }
    req.getProxy().proxyTo(req.getRequestURI());
  }
  /*
  * Returns application route set for specified request. Ideally, this route
  * set should be based on the requesting user's subscribed services. In
  * this example, it is fixed for all users.
  */
  private SipURI[] getRouteSet(SipServletRequest req) {
    return new SipURI[] { createRouteURI("app1"), createRouteURI("app2") };
  }
  private SipURI createRouteURI(String appName) {
    SipURI uri = factory.createSipURI(appName, CLUSTER_ADDRESS);
    uri.setLrParam(true);
    return uri;
  }
}

 


Troubleshooting Application Composition

WebLogic SIP Server examines the first Route header in a message to determine two things:

  1. Does the username portion of the header match the name of a deployed SIP application?
  2. Does the address portion of the header indicate that the application is intended for this WebLogic SIP Server instance?

Both of these conditions must be met in order for the SIP Servlet container to route a request to an application specified in the Route header. If either condition is not met, Weblogic SIP Server uses the default Servlet mapping rules defined in the Servlet's deployment descriptor to process the request.

For example, if username portion of the first Route header does not match a deployed application name, default Servlet mapping rules are used to process the request. Always ensure that the composer application embeds the correct application names into Route headers when chaining applications together.

Even if the username matches a deployed application, the address portion must also match one of the configured addresses for the WebLogic SIP Server instance:

To ensure that the address of an application matches the server address, ensure that the composer application is embedding the proper address string in Route headers. Also ensure that the server instances are configured using the same address string. See loadbalancer and Configuring WebLogic SIP Server Network Resources in Configuring and Managing WebLogic SIP Server.

 

Skip navigation bar  Back to Top Previous Next