【发布时间】:2012-01-26 15:34:55
【问题描述】:
我需要使用 WCF 休息服务发送一个字节数组文件。我必须在 android 中使用 HttpPost 方法发送数据。我使用的代码将状态为 HTTP/1.1 400 Bad Request 错误。
private final static String URI = "http://192.168.1.15/QueryService/Import/Test";
final HttpPost request = new HttpPost(URI);
final HttpClient httpClient = new DefaultHttpClient();
final ByteArrayEntity entity = new ByteArrayEntity(fileToBytes(pathToOurFile));
entity.setContentType("application/octet-stream");
entity.setChunked(true);
request.setEntity(entity);
final HttpResponse hr = httpClient.execute(request);
final StatusLine status = hr.getStatusLine();
httpClient.getConnectionManager().shutdown();
【问题讨论】:
标签: android android-service wcf-rest