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.

Reply via email to