以下代码给出错误请求错误,代码中的任何解决方案或错误。
MultipartEntity entityPost = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
entityPost.addPart("data_1", new StringBody(String.valueOf(feedbackId), Charset.forName("UTF-8")));
entityPost.addPart("file_1", new FileBody(__file));
HttpPost httppost = new HttpPost("http://www.example.com/webservice.asmx/method");
httppost.setEntity(entityPost);
httppost.setHeader("Content-Type", "multipart/form-data");
HttpResponse __response = HttpManager.httpClient().execute(httppost);
网络服务:
public String method() {
try {
System.Web.HttpContext postContext = System.Web.HttpContext.Current;
string data = postContext.Request.Form["data_1"].ToString();
System.Web.HttpFileCollection files = postContext.Request.Files;
System.Web.HttpPostedFile = files[0];
//etc etc
} catch (Exception ex) {
//
}
}
错误 :
org.apache.http.client.HttpResponseException: Bad Request
先感谢您