Performing DNS lookups in Session Initiation Protocol (SIP) applications on Liberty

Use the Domain Resolver API in your application to perform Domain Name System (DNS) lookups of SIP URIs using the RFC 3263 protocol. You can perform synchronous lookups to avoid having to preserve state, which is required for an asynchronous callback. Alternatively, you can perform asynchronous lookups if you need a better performing interface.

Before you begin

In your server.xml file, install and configure the sipServlet-1.1 feature with a domainResolver element. For more information, see Administering Session Initiation Protocol (SIP) on Liberty.

Procedure

  1. Access the Domain Resolver API in your application.
    • Get an attribute from the ServletContext method using com.ibm.websphere.sip.resolver as a key.
      getServletContext().getAttribute("com.ibm.websphere.sip.resolver ")
      
    • Use resource injection.
      @resource 
      DomainResolver resolver
  2. Perform the URI lookup.
    • To use the API synchronously, call the locate(SIPURI) method, which returns the result of the URI resolve request response.
      DomainResolver
      locate(SIPURI)
    • To use the API asynchronously, call the locate(SIPURI, Listener) method, which signals the listener after it finishes. When the result is cached, the listener is triggered on the same caller thread.
      DomainResolver
      locate(SIPURI, Listener)