Android获取程序请求的http,Java-在Android Web服务调用中获取HTTP 406

我通过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 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 nameValuePairs = new ArrayList();

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错误…

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值