So I discovered that I need to add any extra libraries into /war/WEB- INF/lib -- added apache httpclient, apache logging, and apache codec jars.
Now I get this error --- java.net.Socket is a restricted class. Please see the Google App Engine developer's guide But the gwt docs seem to suggest i can use anything i want on the server side: "Tip: Although GWT translates Java into JavaScript for client-side code, GWT does not meddle with your ability to run Java bytecode on your server whatsoever. Server-side code doesn't need to be translatable, so you're free to use any Java library you find useful." Well this one would be useful... any ideas why it is a restricted class? and what that means? Anecdotally i saw that I should be able to use URLConnection? I guess I'll try that. Thanks! On Mar 16, 11:43 am, vegbenz <[email protected]> wrote: > Hi, when i run the code below as standalone pojo, it works fine, but > in my "GreetingServiceImpl" on server it returns 500 error; > > ** please note i DO want to do this from the server. i saw the > tutorial about adding script tags to accomplish this from the client. > I need to do the fetch from the server side for other reasons. > thanks! > > import java.io.IOException; > > import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; > import org.apache.commons.httpclient.HttpClient; > import org.apache.commons.httpclient.HttpException; > import org.apache.commons.httpclient.HttpStatus; > import org.apache.commons.httpclient.methods.GetMethod; > import org.apache.commons.httpclient.params.HttpMethodParams; > > public class TestRemoteCall { > > public static void main(String args[]) { > > HttpClient client = new HttpClient(); > > GetMethod method = new > GetMethod("http://waterdata.usgs.gov/tx/nwis/ > current/? > type=flow&group_key=basin_cd&search_site_no_station_nm=barton"); > > // Provide custom retry handler is necessary > > method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new > DefaultHttpMethodRetryHandler(3, false)); > > try { > // Execute the method. > int statusCode = client.executeMethod(method); > > if (statusCode != HttpStatus.SC_OK) { > System.err.println("Method failed: " + > method.getStatusLine()); > } > > // Read the response body. > byte[] responseBody = method.getResponseBody(); > > // Deal with the response. > // Use caution: ensure correct character encoding and > is not binary > data > // System.out.println(new String(responseBody)); > System.out.println(new String(responseBody)); > > } catch (HttpException he) { > System.err.println("Fatal protocol violation: " + > he.getMessage()); > he.printStackTrace(); > } catch (IOException e) { > System.err.println("Fatal transport error: " + > e.getMessage()); > e.printStackTrace(); > } finally { > // Release the connection. > method.releaseConnection(); > } > } > > } > > HERE is the error message > > import java.io.IOException; > > import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler; > import org.apache.commons.httpclient.HttpClient; > import org.apache.commons.httpclient.HttpException; > import org.apache.commons.httpclient.HttpStatus; > import org.apache.commons.httpclient.methods.GetMethod; > import org.apache.commons.httpclient.params.HttpMethodParams; > > public class TestRemoteCall { > > public static void main(String args[]) { > > HttpClient client = new HttpClient(); > > GetMethod method = new > GetMethod("http://waterdata.usgs.gov/tx/nwis/ > current/? > type=flow&group_key=basin_cd&search_site_no_station_nm=barton"); > > // Provide custom retry handler is necessary > > method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new > DefaultHttpMethodRetryHandler(3, false)); > > try { > // Execute the method. > int statusCode = client.executeMethod(method); > > if (statusCode != HttpStatus.SC_OK) { > System.err.println("Method failed: " + > method.getStatusLine()); > } > > // Read the response body. > byte[] responseBody = method.getResponseBody(); > > // Deal with the response. > // Use caution: ensure correct character encoding and > is not binary > data > // System.out.println(new String(responseBody)); > System.out.println(new String(responseBody)); > > } catch (HttpException he) { > System.err.println("Fatal protocol violation: " + > he.getMessage()); > he.printStackTrace(); > } catch (IOException e) { > System.err.println("Fatal transport error: " + > e.getMessage()); > e.printStackTrace(); > } finally { > // Release the connection. > method.releaseConnection(); > } > } > > } -- 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.
