Wednesday, February 29, 2012

How to POST in REST web service

Hi all,
I am trying to  make a REST call to get the response from Web Service. The code is as below and it works.
public static String makeRestCall(String service)  {
StringBuilder sb = new StringBuilder();
String baseURL = urlsrc;
try {
//set URL
URL url = new URL(baseURL + service);
//make connection
URLConnection urlc = url.openConnection();
BufferedReader br = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String l = null;
while ((l=br.readLine())!=null) {
sb.append(l);
}
br.close();
} catch (Exception ex){
ex.getMessage();
}
return sb.toString();
}


But what are the changes that i need to make so that i can make  a POST call to Web service.
Any help is appreciated.

Thanks  

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment