Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
is there any c# equivalent for MultipartEntity in java or can any one help in transforming this java code to c#

Java
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);
}
Posted
Updated 31-Oct-11 1:58am
v2
Comments
Santosh P Umarani 17-Oct-12 2:49am    
Can anybody please respond to this? Even I'm looking for the solution for the same. Basically looking for equivalent of Multipart data (which is in Java) in .net?

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900