Over the past few days I have been working on a small GWT based
application which retrieves and displays Weather information from
YAHOO RSS in real time.
To get information from the YAHOO RSS feed, I am using the HttpClient
from the org.apache.commons library.
Using this library I attempt to make a call to the RSS feed on the
server side of the GWT application I am building.
The application I have written works fine while run in debug mode
using Eclipse. However when the application is compiled and deployed
on Apache Tomcat 6, it doesn't work anymore. The application simply
makes no call to YAHOO. Evenmore, it seems nothing is happening at all
on the server side of the application. I can't be more specific about
what goes wrong becaue no error is given. I've checked the Apache
Tomcat 6 logs, and no error or any system out information is present
in the logs. The client side GUI loads properly, but as I said,
nothing seems to happen on the server side.
Being completely clueless about what causes this problem, and having
no error feedback to go on. I decided to post the problem here, hoping
someone may know the cause of this.
This is the relevant part of my server sides source code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Iterator;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.GetMethod;
public Weather getWeatherInSingapore() {
System.out.println("Server Reached");
String request = "http://weather.yahooapis.com/forecastrss?
w=1062617&u=c";
Weather weatherReport = new Weather();
HttpClient client = new HttpClient();
GetMethod method = new GetMethod(request);
try {
// Send GET request
int statusCode = client.executeMethod(method);
if (statusCode != HttpStatus.SC_OK) {
System.out.println("Method failed: " +
method.getStatusLine());
}
InputStream rstream = null;
// Get the response body
rstream = method.getResponseBodyAsStream();
// Process the response from Yahoo! Web Services
BufferedReader br = new BufferedReader(new
InputStreamReader(
rstream));
String xml = "";
String line;
while ((line = br.readLine()) != null) {
xml = xml + line;
}
br.close();
weatherReport = this.convertYAHOOWeather(xml);
} catch (IOException e) {
System.out.println("Error");
e.printStackTrace();
}
return weatherReport;
}
Note:
WeatherReport is a custom object I've written myself to contain the
necessary Information
The convertYAHOOWeather is a private function that parses the XML
reply form the YAHOO RSS.
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.