I ran into the same problem.I have written the below client for for my web service.Fortunately it does return an output.Unfortunately I think it is not in proto-buf format.I want to see it in protobuff format.I do not know how protobuff format looks like.You may wan to have a look at the below link:-
https://spring.io/blog/2015/03/22/using-google-protocol-buffers-with-spring-mvc-based-rest-services
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class HttpRestClient {
// http://localhost:8080/customers/
public static void main(String[] args) {
try {
URL url = new URL("http://localhost:8080/customers/1");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Content-Type", "application/x-protobuf");
conn.setRequestProperty("Accept", "application/x-protobuf");
String contentType = conn.getContentType();
System.out.println(contentType);
System.out.println("---------------------------------------------------------------------");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " +
conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new
InputStreamReader((conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
Object response = output;
System.out.println(response);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
If anyone has better suggestions please lemme know.This is how my output looks like:-
application/x-protobuf;charset=UTF-8
Output from Server ....
Chris
Richardson*
[email protected]
As you could see it is not in protobuff format.