我想从我的Android应用程序中的表单发送一些参数(如果我可以使用JsON这样做会很棒).
解决方法 我解决了这个问题至于服务器端
@Postpublic JsONArray serverSidefunction(Representation entity)throws JsONException { try { JsONObject req = (new JsonRepresentation(entity)).getJsonObject(); System.out.println(req.getString(/* filed name */)); System.out.println(req.getString(/* filed name */)); /* * you can retrIEve all the fIElds here * and make all necessary actions */ } catch (IOException e) { e.printstacktrace(); }}
至于AndroID SIDe
httpClIEnt clIEnt = new DefaulthttpClIEnt(); String responseBody; JsONObject JsonObject = new JsONObject(); try{ httpPost post = new httpPost(WebService_URL); JsonObject.put("fIEld1","........."); JsonObject.put("fIEld2","........."); StringEntity se = new StringEntity(JsonObject.toString()); post.setEntity(se); post.setheader(new Basicheader(http.CONTENT_TYPE,"application/Json")); post.setheader("Content-type","application/Json"); Log.e("webservice request","executing"); ResponseHandler responseHandler = new BasicResponseHandler(); responseBody = clIEnt.execute(post,responseHandler); /* * You can work here on your responseBody * if it's a simple String or XML/JsON response */ } catch (Exception e) { e.printstacktrace(); }
我希望这可能有所帮助
总结以上是内存溢出为你收集整理的如何从android传递参数到RESTlet webservice?全部内容,希望文章能够帮你解决如何从android传递参数到RESTlet webservice?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)