本文介绍了等价于MultipartEntity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Java中是否有与MultipartEntity等效的C#,或者可以帮助将该Java代码转换为C#的任何人
is there any c# equivalent for MultipartEntity in java or can any one help in transforming this java code to c#
HttpPost httpPost = new HttpPost("http://www.inspire-geoportal.eu/INSPIREValidatorService/resources/validation/inspire");
//xml response: httpPost.addHeader("Accept", "application/xml");
//html response
httpPost.addHeader("Accept", "text/html");
FileBody dataFile = new FileBody(new File("yourMetadataFile.xml"));
MultipartEntity reqEntity = new MultipartEntity();
reqEntity.addPart("dataFile", dataFile);
httpPost.setEntity(reqEntity);
HttpResponse response = httpclient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
switch (statusCode) {
//OK
case 200: //implement the below method to extract the response
parseServiceResponse(response);
break;
//Exception was thrown
case 400: //implement the below method to handle the exceptions
handleServiceException(response);
break;
//Internal error from the service
default: //implement the below method to handle errors such as internal server error
handleServerError(response);
}
推荐答案
这篇关于等价于MultipartEntity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!