我得到406当我通过机器人application.Can调用REST Web服务的任何一个建议我什么是这个代码中的错误,为什么我收到此错误?
REST Web服务
@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错误...