等价于MultipartEntity [英] equivalent of MultipartEntity

查看:105
本文介绍了等价于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);
}

推荐答案

阅读以下内容:http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/f28c65de-a5ca-4cf1-9f87-39938cf0c012/ [ ^ ]

符合MIME的解析器 [
Read these : http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/f28c65de-a5ca-4cf1-9f87-39938cf0c012/[^]

MIME Compliant Parser[^]



您可以从以下站点使用这些dll:"www.codescales.com/#comment-10928"
MultipartEntit,HttpPost等的类已在此处编写.

谢谢,
Santosh
Hi,
You can use the dlls from this site: "www.codescales.com/#comment-10928"
The class for MultipartEntit, HttpPost etc have been written here.

Thanks,
Santosh


这篇关于等价于MultipartEntity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆