我通过android应用程序调用其余的Web服务时得到406,有人能建议我这段代码中的错误是什么以及为什么我收到此错误吗?
休息网服务
@RequestMapPing(value="/mainreservationChartPost", method = RequestMethod.POST) public @ResponseBody ModelMap getMRChartDataPOST(@modelattribute ("ReservationSummaryRQDTO") ReservationSummaryRQDTO search){ ReservationSummaryDTO returnDataDTO = new ReservationSummaryDTO(); MainReservationChartWSImpl wsImpl = MRWSUtil.getInstance().getWS_ServicePort(); search.setHotelCode("BBH"); search.setReportDate(toXmlDateGMT(new Date())); returnDataDTO = wsImpl.getReservationSummary(search); ModelMap model = new ModelMap(); model.put("reservations", returnDataDTO); return model; }
AndroID代码
public static String POST(String url, ArrayList<nameValuePair> parameter) throws Exception { BufferedReader in = null; try { DefaulthttpClIEnt httpclIEnt = new DefaulthttpClIEnt(); httpPost httpost = new httpPost(url); httpost.setheader("Accept", "application*/*"); httpost.setheader("Content-type", "application/x-www-form-urlencoded"); httpost.setEntity(new UrlEncodedFormEntity(parameter, "utf-8")); httpResponse response = httpclIEnt.execute(httpost); in = new BufferedReader(new inputStreamReader(response.getEntity() .getContent())); StringBuffer sb = new StringBuffer(""); String line = ""; String NL = System.getProperty("line.separator"); while ((line = in.readline()) != null) { sb.append(line + NL); } in.close(); String result = sb.toString(); return result; } finally { if (in != null) { try { in.close(); } catch (Exception e) { e.printstacktrace(); } } } }@OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_main); ArrayList<nameValuePair> nameValuePairs = new ArrayList<nameValuePair>(); nameValuePairs.add(new BasicnameValuePair("hotelCode","BBH")); //nameValuePairs.add(new BasicnameValuePair("reportDate","10-MAY-2013")); //String response=hcc.executehttpPost("http://10.2.241.137/ua_dat/rnd/senddata.PHP", nameValuePairs); try { String response=httpCustomClIEnt.POST("http://10.2.241.33/MRChartService/mainreservationChart.HTML", nameValuePairs); } catch (Exception e) { Log.d("error", e.getMessage().toString()); } }
任何人都可以建议如何解决这个问题..?此代码中的任何错误,因为我收到406错误…
解决方法:
406表示请求的接受标头中正在请求的数据类型与服务器返回的类型不匹配.更改您接受的类型或更改返回的mime类型.
总结以上是内存溢出为你收集整理的Java-在Android Web服务调用中获取HTTP 406全部内容,希望文章能够帮你解决Java-在Android Web服务调用中获取HTTP 406所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)