Home / dotNet
WURFL as a dotNetAPI
Patch file support
|
|
WURFL and dotNet:
by Jose Blanco (jblanco at aurentis dot com)
Although Msft provides mobile web controls for mobile development, wurfl gives to the developer a big possibility for making his own detect routine or even extend those controls.
- Quick Usage
- Changes and improvements in version 1.2
- The sample application
- The wurflApi
- Downloads
- To do list
Quick Usage
First add a reference to the wurflApi.dll. Then code in the aspx file something like:
Dim sReturnedCapability As String
Try
Dim oDeviceFileProcessor _
As New wurflApi.deviceFileProcessor(Server.MapPath("wurfl.xml"))
Dim ojbWurflApi As New wurflApi.capabilitiesGetter(oDeviceFileProcessor)
ojbWurflApi.prepareNavigatorModelCapabilities(request)
sReturnedCapability = ojbWurflApi.getCapability("max_image_width")
Catch ex As Exception
sReturnedCapability = ex.Message.ToString
End Try
Response.Write(sReturnedCapability)
Changes and Improvements in version 1.2
- The API has been broken in 2 classes(deviceFileProcessor and capabilitiesGetter). The idea is preprocess only once the wurfl file. You could put the deviceFileProcessor in global.asax, and reuse it through all the pages of your application(You could see it in the global.asx file of the sample application).
- The capabilitiesGetter has a new function called prepareNavigatorModelCapabilities which could receive a string with the user agent(for test purposes) or the request object(for production environments)
- The capabilitiesGetter has two functions for get capabilities.One called getCapability which receives a string with the requested capability and returns the value. Another called getAllCapabilities which returns a hashtable with all capabilities.
- If the user agent can't be found, the API currently returns the values of "generic" . If you want to change this behavior, in capabilitiesGetter.vb, into the getModelIdByUserAgent function, change the three lines into the If sTmp2 = sTmp Or sTmp = "" Then, by something like Throw New Exception("Model not found")
The sample application
Requirements:
- Microsoft .Net Framework.
- IIS.
Installation process:
- Download the Full Package with source.
- Unzip and execute the .msi file.(If the installer tells to you that wurfl.net is already installed, uninstall it. See above the removal process)
- Say next to all. (NOTE: If you change the virtual directory where you install the application, you must manually modify the wurfl.Net.sln file with notepad or something like this, and change the path to the virtual directory. Example: If you change the virtual directory to wurfl.Net_v_2, you must replace http://localhost/wurfl.net/wurfl.net.vbproj with http://localhost/wurfl.Net_v_2/wurfl.net.vbproj).
- When the installation finish, go to the directory wurfl.Net(Created under the default path defined for IIS applications, usually c:\inetpub\wwwroot).
- Double click over the wurfl.Net.sln file.
In the solution you will find two projects wurfl.Net(the sample) and wurflApi(the API). If you want see the code of the sample, make right click in the wurfl.Net project, over default.aspx and then click View Code.
(NOTE: If when you try to run the project have an error like "Running the project requires setting an initial Web page", make right click over default.aspx file and click in Set as Start Page).
Removal process:
- Go to Control Panel.
- Go to Add/Remove Programs.
- Find wurfl.net
- Uninstall it.
The wurflApi
Requirements:
Installation process:
- The commented source and the documentation of wurlfApi.
- Unzip it.
- Double click over the wurflApi.sln file.
Downloads (Tested under Microsoft .Net Framework 1.1 version 1.1.4322)
To do list
- Create a web service for get capabilities.
- Prepare some type of cache in sample application.
|