WURFL Cloud HTTP that only contains the user-agent string

jimoguns
Posts: 3
Joined: Fri Jul 26, 2013 3:57 am

WURFL Cloud HTTP that only contains the user-agent string

Postby jimoguns » Fri Jul 26, 2013 4:16 am

Is there a WURFL cloud API for request that only contains the user-agent string?(am not talking of WURFL core API)

For example: WURFL core API has this request method:getDeviceForRequest(user-agent).

Do you have the same method for WURFL cloud API?

Because i want to integrate WURFL cloud API to my restful service which used by another application.

This is the way I want to use it:
The application pass "user-agent" to the restful service and the service send the "user agent" to the WURFL and the WURFL will return the device details.

fulvio.crivellaro
Posts: 38
Joined: Tue Jan 31, 2012 10:27 am

Re: WURFL Cloud HTTP that only contains the user-agent strin

Postby fulvio.crivellaro » Fri Jul 26, 2013 8:59 am

Actually, there is no method for performing a match with the user agent String using the Java Cloud API.

Nevertheless, there exists a workaround for this: notice that HttpServletRequest is an interface, hence you could just write a wrapper. WURFL cloud should only use HttpServletRequest.getHeader() and HttpServletRequest.getHeaderNames() methods to perform the matches.
Consider this code as an example:

Code: Select all

class HttpServletRequestWrapper implements HttpServletRequest {
	
	private String ua;
	
	public HttpServletRequestWrapper(String ua) {
		this.ua = ua;
	}
	
	public String getHeader(String name) {
		if ("user-agent".equals(name)) {
			return ua;
		} else {
			return null;
		}
	}
	
	public Enumeration<String> getHeaderNames() {
		Vector<String> headerNames = new Vector<String>(1);
		headerNames.add("user-agent");
		return headerNames.elements();
	}
}
All other inherited methods should do nothing, and return null if needed.
This is just an example: a better solution would be to map all header fields, instead of just the user agent.

The method signature also takes as an input a HttpServletResponse. This object is only used by the Cookie cache to store data.
As a consequence, only if you use Cookie cache you are constrained to provide a non-null HttpServletResponse reference.
In this case, the only method you have to take care about is HttpServletResponse.setCookie(Cookie cookie); but of course you also need to manage interactions with HttpServletRequest.getCookies() to allow the Cookie cache to work correctly.

Do not hesitate to ask more details, or if you need help to implement this solution.

jimoguns
Posts: 3
Joined: Fri Jul 26, 2013 3:57 am

Re: WURFL Cloud HTTP that only contains the user-agent strin

Postby jimoguns » Fri Jul 26, 2013 9:40 am

Thank for the information.
Looking at your response, I would prefer to go along with WURFL core API, because I managed it works with my CXF restFul service.

Any clients application developed with any languages can ask device details via my RestFul service and that exactly what I want.

But what is disadvantage of using WURFL core API against WURFL cloud API?

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: WURFL Cloud HTTP that only contains the user-agent strin

Postby sm_support2 » Fri Jul 26, 2013 9:52 am

There are two potential disadvantages of WURFL OnSite over the WURFL Cloud:

- Updates. The Cloud is automatically updated without any action required at least once per week. OnSite requires that you or your team updates the wurfl.xml regularly (paying customers can set this up automatically. Community users will need to do this manually, in addition to the obligation to open-source the complete code base of their application of course).

- Pricing: this point is actually moot (it depends on the case), but the WURFL Cloud has a tendency to be cheaper than OnSite. Again this may or may not apply to your case.

Of course, there are other advantages for using OnSite (such as, avoiding dependencies on an external system, the ability to manage your own WURFL patch files).

Thanks

jimoguns
Posts: 3
Joined: Fri Jul 26, 2013 3:57 am

Re: WURFL Cloud HTTP that only contains the user-agent strin

Postby jimoguns » Fri Jul 26, 2013 1:34 pm

Thanks.
how much does it cost? I mean if I want to setup the automatically update of the WURFL file.

sm_support2
Posts: 294
Joined: Mon Jun 20, 2011 5:04 pm

Re: WURFL Cloud HTTP that only contains the user-agent strin

Postby sm_support2 » Fri Jul 26, 2013 3:32 pm

jimoguns wrote:Thanks.
how much does it cost? I mean if I want to setup the automatically update of the WURFL file.
We respectfully suggest that you access our FAQ at http://www.scientiamobile.com/support

You will find plenty of information there. Thank you


Who is online

Users browsing this forum: No registered users and 4 guests