ScientiaMobile WURFL Cloud Client for Java

Introduction

The WURFL Cloud Service by ScientiaMobile, Inc., is a cloud-based mobile device detection service that can quickly and accurately detect over 500 capabilities of visiting devices. It can differentiate between portable mobile devices, desktop devices, SmartTVs and any other types of devices that have a web browser.

In order to use the WURFL Cloud client you need to obtain an API key from Scientiamobile. The WURFL Cloud API is offered in two main flavors - Base and Premium. The Base version is limited to returning only a small number of capabilities; the Premium version doesn't have an upper limit to the number of returned capabilities and also offers more caching options for improving the overall performance. Once you've properly set up an account, you can download the cloud client and receive an API key to successfully use the library. You can create an account by visiting ScientiaMobile.com.

Installation

If you are reading this, you have probably extracted the Cloud Client files. You should put them somewhere on your server that is accessible from your web application.

Setup a Development Environment

  • Download and Install a Java JDK version 1.5 or greater
  • Download and Install Apache Tomcat version 6 or greater
  • Download and Install Apache An

Create a JAVA_HOME Environment Variable which points to the location of your Java JDK installation (eq: C:\Program Files (x86)\Java \jdk1.6.0_31).

Create an ANT_HOME Environment Variable which points to the location of your Ant installation (eq: C:\apache-ant-1.8.3). Add %ANT_HOME%/bin to your PATH System Variable.

Note for Windows users: If you are setting your environment variables using a terminal window (cmd.exe), you must quit and restart the Command Prompt utility for the environment variables you have defined to be recognized.

Build a Sample Client

To build and test the sample code, you will first need to edit two files which came with the WURFL Cloud Client.

Locate the MyCloudClientServlet.java file and open it with a text editor.

Change the value of the TEST_API_KEY variable to your API Key. You can retrieve your API Key in your ScientiaMobile account. Save and close the file.

Locate the build.properties file and open it with a text editor. Set the value of tomcat.home to the location of your tomcat installation and other settings as explained. Save and close the file.

Note: Please observe that this step assumes that Tomcat is configured to 'talk' to other applications. Tomcat must be running and you must have a user configured with 'manager-script' role. For this step, please read the how-to in <tomcat-home>/conf/tomcat-users.xml. If this is not the case, you can skip this step and deploy/copy the '.war' file (more later) following the procedure that you normally follow to install web applications on your Java application server.

If your Tomcat installation is accessible from Ant, the ant install command will deploy the cloud client automatically.

Warning: manager paths are slightly different between Tomcat 6 and Tomcat 7.

Open a terminal window and change to the WURFL Cloud Client directory. Type ant and hit enter. This builds a .war file in dist folder.

Assuming you are using Tomcat, copy the '.war' file in the dist/ directory to the tomcat webapps directory. For other application servers, simply follow the normal procedure to deploy .war files.

If not already started, start Tomcat.

Test the WURFL Cloud Client

Depending on the type of plan you purchased, you have installed one of two kinds of Cloud Clients: simple or premium.

Please Note that it may take a few minutes from the time that you signup for your WURFL Cloud API Key to become active.

Assuming you have installed Tomcat and all of the traditional defaults apply, you can access the Cloud Client from your browser at one of the following URLs:

http://localhost:8080/simple-client-example-1.0/

http://localhost:8080/premium-client-example-1.0/

(or, if you have hot-deployed with ant, respectively)

http://localhost:8080/simple-client-example

http://localhost:8080/premium-client-example)

Note: if your application server is not Tomcat, or you changed some of the defaults, you will need to adjust your URLs accordingly.

Integration

You should review the included example code (MyCloudClientServlet.java and response.jsp) to get a feel for the Client API, and how best to use it in your application.


© 2024 ScientiaMobile Inc.
All Rights Reserved.

NOTICE: All information contained herein is, and remains the property of ScientiaMobile Incorporated and its suppliers, if any. The intellectual and technical concepts contained herein are proprietary to ScientiaMobile Incorporated and its suppliers and may be covered by U.S. and Foreign Patents, patents in process, and are protected by trade secret or copyright law. Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained from ScientiaMobile Incorporated.