using webservice from java servlet

Using Tera-WURFL's Remote Webservice Client. This includes the pre-packaged clients that come with Tera-WURFL and any other client you may have made to use the webservice.

using webservice from java servlet

Postby renclav » Thu Jun 23, 2011 4:28 am

Hi All

I am a bit dumbfounded as to why this occurs but here goes:
My setup -
ubuntu server hosting latest tera-wurfl with mysql 5 and php 5
clients are on windows tomcat 7 machines using java servlets and jsp's

occasionally I get an empty response string from the webservice. I use this code to access it:
Boolean work = true;
String decode = "";
String ho = "";
try {
ua = request_ua;
URL u = new URL((Config.teraWurfl + "ua=" + ua + "&search=model_name|brand_name|j2me_midp_1_0|j2me_midp_2_0|match&format=json").replaceAll(" ", "%20"));
URLConnection connect = u.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(connect.getInputStream()));
while((ho = in.readLine()) != null) {
decode += ho;
}
in.close();
if(!decode.isEmpty()) {
JSONParser parser = new JSONParser();
JSONObject orig = (((JSONObject) parser.parse(decode)));
if (orig != null) {
JSONObject obj = ((JSONObject) orig.get("capabilities"));
if (obj != null) {
brand = obj.get("brand_name").toString();
model = obj.get("model_name").toString();
midp1 = (Boolean) obj.get("j2me_midp_1_0");
midp2 = (Boolean) obj.get("j2me_midp_2_0");
match = (Boolean) obj.get("match");
if (brand == null || model == null || midp1 == null || midp2 == null || match == null) {
work = false;
}
} else {
work = false;
}
} else {
work = false;
}
}
else
work = false;
} catch (Exception ex) {
work = false;
ex.printStackTrace();
}

where the ua is passed via method parameter

as of now, whenever this occurs I fall back to java wurfl using the same ua which always works.

Any thoughts, suggestions?

Thank You in advance :mrgreen:

Dylan
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Re: using webservice from java servlet

Postby kamermans » Thu Jun 23, 2011 9:47 am

Perhaps the UA is not being URL-Encoded and it's messing up the URL parameters. You could try this by using a UA with a '&' character in it. You can also put the UA in the actual HTTP User-Agent header and leave it out of the URL Parameters.
Thanks,

Steve Kamerman
Tera-WURFL Author
COO of ScientiaMobile

IMPORTANT ANNOUNCEMENT! Tera-WURFL and WURFL have joined forces! We have launched ScientiaMobile to provide commercial support for our device detection solutions.

Tera-WURFL.com | Device Explorer
kamermans
Site Admin
 
Posts: 323
Joined: Wed Mar 10, 2010 12:06 pm
Location: Fort Worth, TX

Re: using webservice from java servlet

Postby renclav » Fri Jun 24, 2011 7:19 am

Hi Kamermans

Thanks you, I will try adding the UA string to the header and leave it out of the URL parameters and let you know.
On a side note, I have noticed that even though Tera-Wurfl config claimed to have set the memory limit for php, I still got the run out of memory (128mb) error. I have set the global php limit to 1024mb for now.

Any recommendations for my apache2 conf settings?This has been recommended:
KeepAlive Off
MaxKeepAliveRequest=2
MaxClients = 1000
MaxRequestsPerChild 1000
MinSpareServers 15
MaxSpareServers 25
StartServers 20

This is VM solely for Tera-Wurfl :)

Thank You :mrgreen:
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Re: using webservice from java servlet

Postby kamermans » Fri Jun 24, 2011 9:07 am

There was a memory-hogging bug in 2.1.4 that caused some systems to use a large amount of RAM during a reload, but this has been fixed in 2.1.5. The Apache settings look good. You will also want to crank up your MySQL settings, like the query cache. Also, if you need something really fast, we do offer enterprise (redundant, high-performance) installations from ScientiaMobile.
Thanks,

Steve Kamerman
Tera-WURFL Author
COO of ScientiaMobile

IMPORTANT ANNOUNCEMENT! Tera-WURFL and WURFL have joined forces! We have launched ScientiaMobile to provide commercial support for our device detection solutions.

Tera-WURFL.com | Device Explorer
kamermans
Site Admin
 
Posts: 323
Joined: Wed Mar 10, 2010 12:06 pm
Location: Fort Worth, TX

Re: using webservice from java servlet

Postby renclav » Mon Jun 27, 2011 2:56 am

:)
Since the apache and mysql 'juicing' the Tera has working like a charm. Very rarely, the Tera-wurlf server fails to respond. Find this odd as both Tera-Wurfl and it's clients are hosted by the same company. Looking into the enterprise solution, could you please give me an idea of the costs?

Side note:
Tera's performance is far superior to the java api! Frankly, I think the only lag between requests and responses is time it take to print out to my monitor :shock:

Now I just need to figure out why the Tera service occasionally fails to respond and it's bye bye java api :D
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Re: using webservice from java servlet

Postby renclav » Mon Jun 27, 2011 3:38 am

quick edit, I requested my Tera VM be 'Supermanned'... well, no more failed to respond errors now :D :D :D One device does have a fallback error though,the error log wont tell me which one though.
on a side note, the wurfl db is only 90% correct in my opinion. Our tester invalidates the wurfl results almost every time he gets a new batch of cells :/
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Re: using webservice from java servlet

Postby kamermans » Mon Jun 27, 2011 11:56 am

I'm glad it's working well for you! I'll PM you about the Enterprise version, but you can also use http://www.scientiamobile.com/site/LicenseInquiry to request info.

If your tester is so quick to find errors in the WURFL data, it seems only obvious that he/she/you would be willing to provide these details to us so we can improve the data :)
Thanks,

Steve Kamerman
Tera-WURFL Author
COO of ScientiaMobile

IMPORTANT ANNOUNCEMENT! Tera-WURFL and WURFL have joined forces! We have launched ScientiaMobile to provide commercial support for our device detection solutions.

Tera-WURFL.com | Device Explorer
kamermans
Site Admin
 
Posts: 323
Joined: Wed Mar 10, 2010 12:06 pm
Location: Fort Worth, TX

Re: using webservice from java servlet

Postby renclav » Thu Jul 07, 2011 2:34 am

:)
I submit often enough, fear not.
Sorry, I can not reply to messages, but we will be in contact soon. Very interested in the Cloud Wurfl.

Thank You
Dylan
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Re: using webservice from java servlet

Postby kamermans » Thu Jul 07, 2011 9:23 am

Ok, well thanks in that case :)

We're planning to start the beta testing for WURFL Cloud very soon. Feel free to drop us a line a wurfl-cloud-beta@scientiamobile.com if you want to help us with the beta testing!
Thanks,

Steve Kamerman
Tera-WURFL Author
COO of ScientiaMobile

IMPORTANT ANNOUNCEMENT! Tera-WURFL and WURFL have joined forces! We have launched ScientiaMobile to provide commercial support for our device detection solutions.

Tera-WURFL.com | Device Explorer
kamermans
Site Admin
 
Posts: 323
Joined: Wed Mar 10, 2010 12:06 pm
Location: Fort Worth, TX

Re: using webservice from java servlet

Postby renclav » Tue Jul 19, 2011 8:06 am

Hi Steve,

Sorry for the late replies, a new project reared it's head...
Could you let me know the updating of the Cloud wurfl process?

Thank You
Dylan
renclav
 
Posts: 11
Joined: Thu Jun 23, 2011 4:21 am

Next

Return to Using the Remote Webservice

Who is online

Users browsing this forum: No registered users and 1 guest

cron