Tuesday, 9 December 2014

Stream Based Reading of Large XML file using REST Call



I need to process large XML files each of which is over 7 GB using Web API for Bulk operations. For Bulk operations, I am using CSV Reader Library1. I need to have suggestions on how to pass and read XML files via POST Request. Without Web API, actually CSV Reader has internal reading mechanism and needs the xml file path, textreader or stream object to read XML using XPATH. Here is signature for my POST method:



public void Post(HttpRequestMessage request)
{
string test = request.Content.ReadAsStringAsync().Result;
TextReader inputstream = new StringReader(test);
string temp = inputstream.Read().ToString()


db2.PerformBlcp(inputstream); // db2 is object of DBContext class (using EF)
}


This is not working..


What exactly I need is : 1) How can I get xml file inside post method, either HttpRequestMessage , string or object? 2) Then I need to pass the xml to CSVReader that will finally read and perform bulk operation


As the size is large, so stream based processing is asked to me. Please suggest solutions..


No comments:

Post a Comment