How to POST in REST web service

90 views
Skip to first unread message

jayalakshmi jahagirdar

unread,
Mar 1, 2012, 1:04:51 AM3/1/12
to Google-We...@googlegroups.com
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  

FrugoFrog

unread,
Mar 1, 2012, 4:27:38 AM3/1/12
to google-we...@googlegroups.com
What sort of content are you getting back?
Would a RequestBuilder be right thing for you?
(http://code.google.com/webtoolkit/doc/latest/DevGuideServerCommunication.html
# HTTP client types )


Am 1. März 2012 06:04 schrieb jayalakshmi jahagirdar
<jayalakshmi...@gmail.com>:

> --
> 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-we...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-web-tool...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/google-web-toolkit?hl=en.

jayalakshmi jahagirdar

unread,
Mar 1, 2012, 4:35:10 AM3/1/12
to google-we...@googlegroups.com
Thanks for the reply 
I am making use of RPC call.I get back XML response.My server side code is what i pasted in previous mail. Similarly i need some modification so that i can post the request as well.Right now  i am able to get XML response  from  RESTful web service.
 
Thanks

JoseM

unread,
Mar 1, 2012, 11:18:30 AM3/1/12
to google-we...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages