Somms.NWURFL API (English)

What is?

Somms.NWURFL is an API for WURFL library developed in .NET using C# 2.0. It is focused in abstraction of data access, and WURFL evolution: Somms.NWURFL provides a collection of interfaces to be implemented for data access layer, and core functions for searching devices by UserAgent strings.

What’s new?

Concept & Search Algorithm

WURFL is more than just an XML file, WURFL is the data stored in it. Regardless of how WURFL is stored, in memory like a hashtable, a database or an XML file, you will have the same data with a similar structure. The way managing this data is also similar, and can be abstracted. So here is where Somms.NWURFL have the point. It tries to unify different APIs, each one using its own search algorithm, and get one common logic for search algorithm bassed in WURFL evolution.


You can download Somms.NWURFL from Sourceforge.

It includes two data access libraries, one for XML file using Margl.Wurfl, and other one for MySQL reading data stored with Tera-WURFL. See Test projects for usage info.

Basic Description

The core of Somms.NWURFL are two interfaces, IWurflDevice and IWurflProvider, implemented respectively by WurflDevice class and WurflProvider class.


This class is a dictionary with device data. It is returned by search functions of WurflProvider.


This abstract class has all main functions. Manages the cache, and has the main algorithm structure for search by UserAgent:

  • Search in cache. If no result,continue.
  • Search exact match in WURFL. If no result,continue.
  • Search strippingUserAgent. If no result,continue.
  • Extract possible info from UserAgent, and return a generic device with no id filled with this ingo . If no result, return null.
  • It also has abstract functions for data access.

    Improved Stripping Search Algorithm

    The StrippingManagerClass provides functionallity for searching a device stripping UserAgent. It tries to avoid false positives, and to find a match consuming as less resources as possible.

    This is the algorithm:

  • Split UserAgent in “tokens” (string splitted by spaces and slashes).
  • Remove last token and search in WURFL with regex ^tmpUA.* (being tmpUA the partial UAgent)
  • If we have ONLY ONE result, return it as success.
  • If we have more than one
  • Search if one of them is an exact match for tmpUA. If so, return it as success.
  • We are going to get back to previous UAgent (with last removed token), and strip character by character
  • Remove last character and search in WURFL with regex ^tmpUA.* (being tmpUA the partial UAgent)
  • If we have ONLY ONE result, return it as success.
  • If we have more than one it is impossible to give an accurate result. Return null as failure.
  • If we have no result, remove next character
  • If we have no result, remove next token
  • It first tries to find a result stripping by tokens. This is faster than character stripping. If it finds more than one result it does a subsearch from last no-success UserAgent string, trying to get an accurate result with character stripping. It only will return a success response if have only one device.

    Heuristic Search Algorithm

    It is under development, since I have never needed it because search stripping algorithm is very good :D . This algorithm is only used when a device is not in WURFL. At the moment, in this case report UAgent and UAProf to WURFL crew if possible.


    To be done:

    • Complete heuristic search algorithm.
    • Integration with ASP.NET browserCaps library.


    This are fragments of a real log file:



    2007-09-03 09:44:52,140 [3856] WARN Marg.Wurfl.WurflIndex - Device with user_agent='Nokia6288/2.0 (05.92) Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/' not found

    2007-09-03 09:44:52,140 [3856] INFO Somms.NWURFL.Framework.Search.StrippingManager - Trying to find something by tokens

    Page 1 of 3 | Next page