Retrieving XML from a C# function on WCF - c#

I have a WCF service that I'm using for calling a C# function via URL, this is the code that I use for the url:
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml, UriTemplate = "?GetValuesVar={Var}")]
string getHisUmsTimeRedVar(string Var);
Once donde that I'm using the parameters of the URL for calling a function and to retrieve a value. My problem is that all the XML code is between <string></string> tags.
<string>
<?xml version="1.0"?><ArrayOfHistoricVal
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HistoricVal>
<Date>2016-05-31T22:00:00</Date><Value>2060</Value>
</HistoricVal>
</ArrayOfHistoricVal>
</string>
Is there a way to retrieve this values as a normal XML instead of between those two <string></string> tags?
Edit: The values to get are in a function like this one:
public string getHisUmsTimeRedVar(string idVar)
{
try
{
ADAMUtil.Log.info("getHisUmsTimeRed. Empieza = ");
DateTime FechaIni = new DateTime(2015, 05, 05, 0, 0, 0);
DateTime FechaFin = new DateTime(2018, 05, 05, 0, 0, 0);
List<HistoricVal> list = new List<HistoricVal>();
List<His> Historicos = null;
ADAMUtil.Log.info("getHisUmsTimeRed. Empieza1 = ");
Historicos = getHisUmsTimeRed("admin", "admin", Convert.ToInt64(idVar), 14, null, 0, 0, FechaIni, FechaFin, 0, "Romance Standard Time");
ADAMUtil.Log.info("getHisUmsTimeRed. Historicos = " + Historicos.Count);
for (int i = 0; i < Historicos.Count; i++)
{
HistoricVal item = new HistoricVal();
item.Date = Historicos[i].IniDat;
item.Value = Historicos[i].Val;
list.Add(item);
}
String xmlDoc;
xmlDoc = toXML.VartoXML(list);
//Browser.BrowserOpen();
return xmlDoc;
}
catch (Exception ex)
{
ADAMUtil.Log.info("getHisUmsTimeRed. ex = " + ex.ToString() + ex.StackTrace.ToString());
return null;
}
}
And the webinvoke must be an Stream, not a string.
[WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Xml,
ResponseFormat = WebMessageFormat.Xml, UriTemplate = "?GetValuesVar={Var}")]
stream getHisUmsTimeRedVar(string Var);

The problem with your XML string is that it is erroneous XML: the XML declaration should be at the very start.
You can't easily convert it to a XElement or XDocument like this.
There are thus two solutions:
Change your method so that it doesn't return a string, but a XElement in the first place.
Work with your string yourself to remove the additional tags. This solution is not robust to change or edges cases, and I recommend you use the first one. But if you are unable to change the called method, this will at least help you out :
//Trims 8 characters (<string>) at the beginning and 9 at the end.
String correctString = yourString.Substring(8, yourString.Length - 17);
EDIT: After discussing the issue in the comments, it seemed that only the browser displayed the <string> tags, and they were not present in the XML file. This was due to it serializing your string object, most likely.
By either serializing it yourself and passing this to your browser with XElement.Parse() or changing the type of your object directly, the browser was able to understand what it was supposed to display.

Change
public string getHisUmsTimeRedVar
To
public XDocument getHisUmsTimeRedVar
to return proper xml not involved in a string tag.

Related

Return XML document with REST API

I would like to return a xml document from rest api request:
[HttpPost]
public string getClassXml(HttpRequestMessage req)
{
var response = Request.CreateResponse(HttpStatusCode.OK);
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
ClassXML classid = new ClassXML();
XmlDocument doc = new XmlDocument();
try
{
var data = req.Content.ReadAsStringAsync().Result;
classid = serializer.Deserialize<ClassXML>(data.ToString().Trim());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
string path = ASDb.ReadValue("SELECT definitionxml FROM alclass WHERE classid='" + classid.classID + "'").ToString();
XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "Resource\\" + percorso);
reader.Read();
doc.Load(reader);
return doc.innerXml;
}
But in this way I get a string, I would like to have a XmlDocument not a string. I tried also to return the XmlDocument doc, but it gives me an error: he 'ObjectContent`1' type failed to serialize the response body for content type 'application/xml; charset=utf-8'.
Do you have any ideas?
As someone wrote here just a few seconds ago (but then deleted his answer) the problem is that XmlDocument is not serializable, if you use XmlElement instead is ok. Here is what I did:
[HttpPost]
public XmlElement getClassXml(HttpRequestMessage req)
{
var response = Request.CreateResponse(HttpStatusCode.OK);
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
ClassXML classid = new ClassXML();
XmlDocument doc = new XmlDocument();
try
{
var data = req.Content.ReadAsStringAsync().Result;
classid = serializer.Deserialize<ClassXML>(data.ToString().Trim());
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
string path = ASDb.ReadValue("SELECT definitionxml FROM alclass WHERE classid='" + classid.classID + "'").ToString();
XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "Resource\\" + percorso);
reader.Read();
doc.Load(reader);
XmlElement element = doc.DocumentElement;
return element;
}
Perhaps the issue isn't with your API layer, but when you're trying to use your XmlTextReader?
XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "Resource\\" + percorso);
What does your XML that you're trying to read in look like? Have you checked that it's well formed?
In terms of "returning XML document with REST API", I would suggest that you just output the XML document as a string with the appropriate MIME type, doing something like:
[HttpPost]
public HttpResponseMessage getClassXml(HttpRequestMessage req)
{
...
XmlTextReader reader = new XmlTextReader(AppDomain.CurrentDomain.BaseDirectory + "Resource\\" + percorso);
reader.Read();
doc.Load(reader);
HttpResponseMessage response = new HttpResponseMessage { Content = new StringContent(doc.innerXml, Encoding.UTF8,"application/xml") };
return response;
}
REST API outputs should map to standard internet mime types (eg JSON data, images, text, etc - not XmlDocument). Whatever is consuming your REST API can just take the text and turn it into a XmlDocument if necessary.
As an aside, you don't seem to even use half the code in the example you provided and you can probably clean it up:
string path = ASDb.ReadValue("SELECT definitionxml FROM alclass WHERE classid='" + classid.classID + "'").ToString();
Sorry but if I now want to change from HttpPost to HttpGet how would I get the parameters in the following url: http://localhost/arcosat/api/ws/GetClassXml?classid=myclass
I want to get the "myclass" string but with req.Content.ReadAsStringAsync().Result it doesn't work anymore

How Can I add XML declaration?

I Have this Xml output from URL XML
using HTTP GET method
How Can I add this XML declaration?
?xml version="1.0" encoding="ISO-8859-1"?>
This is ServiceContract
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
//BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "{id}")]
XElement GetRecipesByID(string id);
This is implementation,
I convert DataTable To Xml and get from URL
public XElement GetRecipesByID(string id)
{
StringWriter str = new StringWriter();
DataSet dataSet = new DataSet();
dataSet.Tables.Add(Table);
XmlTextWriter xtext = new XmlTextWriter(str);
xtext.Formatting = Formatting.Indented;
xtext.WriteStartDocument();
xtext.WriteStartElement("rss");
xtext.WriteAttributeString("version", "2.0");
xtext.WriteStartElement("channel");
xtext.WriteElementString("title", "GetCard");
xtext.WriteElementString("link", "10.0.0.253");
xtext.WriteElementString("lastBuildDate", " ");
xtext.WriteElementString("generator", "Alikas Feed");
xtext.WriteElementString("error", error);
xtext.WriteElementString("cardid", "RX0016502");
xtext.WriteElementString("name", " ");
xtext.WriteElementString("passport_id", "60001082881");
xtext.WriteElementString("tel", " ");
xtext.WriteEndElement();
xtext.WriteEndDocument();
result = str.ToString();
xtext.Close();
XmlDocument doc = new XmlDocument();
doc.Save(str);
return XElement.Parse(result);
}
When I save this xml in file there is xml declaration but when I try to get this xml from URL xml declaration doesn't show.
I need to show this declaration from URL.
Thank you
WriteStartDocument should already be adding the XML declaration. It uses the Encoding specified by your TextWriter.
You're using a StringWriter which will always report UTF-16 as .NET Strings are in UTF-16. To get ISO-8859-1, you'll need to construct a StreamWriter or some other TextWriter with an explicit encoding.
Have you considered creating an XDocument directly? No need to use XmlWriter in that case.
Try following :
string header = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><rss version=\"2.0\"/>";
XDocument doc = XDocument.Parse(header);
XElement rss = doc.Root;
Boolean error = false;
rss.Add(new XElement("channel", new object[] {
new XElement("title", "GetCard"),
new XElement("link", "10.0.0.253"),
new XElement("lastBuildDate", " "),
new XElement("generator", "Alikas Feed"),
new XElement("error", error),
new XElement("cardid", "RX0016502"),
new XElement("name"),
new XElement("passport_id", "60001082881"),
new XElement("tel")
}));
doc.Save(#"c:\temp\test.xml");
There is an special method for this:
var xmlDoc = new XmlDocument();
xmlDoc.CreateXmlDeclaration("1.0", "ISO-8859-1", null);
xmlDoc.Save(str);
Note from the msdn on encoding parameter: This is the encoding that is used when you save the XmlDocument to a file or a stream; therefore, it must be set to a string supported by the Encoding class, otherwise Save fails.
This seems to work for me
XDocument xel = XDocument.Parse( "<root><el>123</el></root>" );
xel.Declaration = new XDeclaration( "1.0","UTF-8","true" );
xel.Save( #"c:\temp.xml" );

Accessing xmlNodeList with partial namespaces(Xpath)

I have been digging through every example I can find related to Xpath and XML parsing. I can't find a close enough example to the XML I have to deal with that makes any sense to me. I am having an extremely difficult time wrapping my head around Xpath in particular but also XML parsing in a more general sense. The complexity of the file I'm working with is not making it easier to understand.
I have an XML file coming from a remote source which I have no control over.
The file is:
<AssetWarrantyDTO xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Dell.Support.AssetsExternalAPI.Web.Models.V1.Response">
<AdditionalInformation i:nil="true"/>
<AssetWarrantyResponse>
<AssetWarrantyResponse>
<AssetEntitlementData>
<AssetEntitlement>
<EndDate>2010-12-20T23:59:59</EndDate>
<EntitlementType>EXTENDED</EntitlementType>
<ItemNumber>983-4252</ItemNumber>
<ServiceLevelCode>ND</ServiceLevelCode>
<ServiceLevelDescription>Next Business Day Onsite</ServiceLevelDescription>
<ServiceLevelGroup>5</ServiceLevelGroup>
<ServiceProvider>UNY</ServiceProvider>
<StartDate>2008-12-21T00:00:00</StartDate>
</AssetEntitlement>
<AssetEntitlement>
<EndDate>2010-12-20T23:59:59</EndDate>
<EntitlementType>EXTENDED</EntitlementType>
<ItemNumber>987-1139</ItemNumber>
<ServiceLevelCode>TS</ServiceLevelCode>
<ServiceLevelDescription>ProSupport</ServiceLevelDescription>
<ServiceLevelGroup>8</ServiceLevelGroup>
<ServiceProvider>DELL</ServiceProvider>
<StartDate>2008-12-21T00:00:00</StartDate>
</AssetEntitlement>
<AssetEntitlement>
<EndDate>2008-12-20T23:59:59</EndDate>
<EntitlementType>INITIAL</EntitlementType>
<ItemNumber>984-0210</ItemNumber>
<ServiceLevelCode>ND</ServiceLevelCode>
<ServiceLevelDescription>Next Business Day Onsite</ServiceLevelDescription>
<ServiceLevelGroup>5</ServiceLevelGroup>
<ServiceProvider>UNY</ServiceProvider>
<StartDate>2007-12-20T00:00:00</StartDate>
</AssetEntitlement>
<AssetEntitlement>
<EndDate>2008-12-20T23:59:59</EndDate>
<EntitlementType>INITIAL</EntitlementType>
<ItemNumber>987-1308</ItemNumber>
<ServiceLevelCode>TS</ServiceLevelCode>
<ServiceLevelDescription>ProSupport</ServiceLevelDescription>
<ServiceLevelGroup>8</ServiceLevelGroup>
<ServiceProvider>DELL</ServiceProvider>
<StartDate>2007-12-20T00:00:00</StartDate>
</AssetEntitlement>
</AssetEntitlementData>
<AssetHeaderData>
<BUID>11</BUID>
<CountryLookupCode>US</CountryLookupCode>
<CustomerNumber>64724056</CustomerNumber>
<IsDuplicate>false</IsDuplicate>
<ItemClassCode>`U060</ItemClassCode>
<LocalChannel>17</LocalChannel>
<MachineDescription>Precision T3400</MachineDescription>
<OrderNumber>979857987</OrderNumber>
<ParentServiceTag i:nil="true"/>
<ServiceTag>7P3VBU1</ServiceTag>
<ShipDate>2007-12-20T00:00:00</ShipDate>
</AssetHeaderData>
<ProductHeaderData>
<LOB>Dell Precision WorkStation</LOB>
<LOBFriendlyName>Precision WorkStation</LOBFriendlyName>
<ProductFamily>Desktops & All-in-Ones</ProductFamily>
<ProductId>precision-t3400</ProductId>
<SystemDescription>Precision T3400</SystemDescription>
</ProductHeaderData>
</AssetWarrantyResponse>
</AssetWarrantyResponse>
<ExcessTags>
<BadAssets xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</ExcessTags>
<InvalidBILAssets>
<BadAssets xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</InvalidBILAssets>
<InvalidFormatAssets>
<BadAssets xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"/>
</InvalidFormatAssets>
</AssetWarrantyDTO>
Here is the Final code not including the setting of the URI variable for the API URL.
protected void Unnamed1_Click(object sender, EventArgs e)
{
string Serial = TextBox1.Text.ToUpper();
URI = String.Format(URI, Serial);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URI);
request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3";
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
CookieContainer aCookie = new CookieContainer();
request.CookieContainer = aCookie;
WebResponse pageResponse = request.GetResponse();
Stream responseStream = pageResponse.GetResponseStream();
string xml = string.Empty;
using (StreamReader streamRead = new StreamReader(responseStream))
{
xml = streamRead.ReadToEnd();
}
XmlDocument doc1 = new XmlDocument();
doc1.LoadXml(xml);
string _byteOrderMarkUtf8 = Encoding.UTF8.GetString(Encoding.UTF8.GetPreamble());
if (xml.StartsWith(_byteOrderMarkUtf8))
{
var lastIndexOfUtf8 = _byteOrderMarkUtf8.Length - 1;
xml = xml.Remove(0, lastIndexOfUtf8);
//Label2.Text = "BOM found.";
}
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc1.NameTable);
nsmgr.AddNamespace("j", "http://schemas.datacontract.org/2004/07/Dell.Support.AssetsExternalAPI.Web.Models.V1.Response");
XmlNodeList nodes = doc1.SelectNodes(".//j:AssetWarrantyResponse/j:AssetWarrantyResponse/j:AssetEntitlementData", nsmgr);
//Make a list to hold the start dates
System.Collections.ArrayList startDates = new System.Collections.ArrayList();
//Make a list to hold the end dates
System.Collections.ArrayList endDates = new System.Collections.ArrayList();
//Create a regex for finding just the date and discarding the time value which can alter tha date if the time is 24:00 (euro standard)
Regex r = new Regex(#"\d{4}-\d{1,2}-\d{1,2}", RegexOptions.IgnoreCase);
//Set the culture to format the date as US region
CultureInfo dtFormat = new CultureInfo("en-US", false);
foreach (XmlNode node in nodes)
{
foreach (XmlNode childNode in node.ChildNodes)
{
string startDate = childNode["StartDate"].InnerText;
if (startDate != null)
{
MatchCollection mcl1 = r.Matches(startDate);
startDates.Add(DateTime.Parse(mcl1[0].ToString(), dtFormat));
}
string endDate = childNode["EndDate"].InnerText;
if (endDate != null)
{
MatchCollection mcl2 = r.Matches(endDate);
endDates.Add(DateTime.Parse(mcl2[0].ToString(), dtFormat));
}
}
startDates.Sort();
endDates.Sort();
DateTime wStartDate = new DateTime();
DateTime wEndDate = new DateTime();
//if (dates.Count > 1) wStartDate = (DateTime)dates[dates.Count - 1];
if (startDates.Count >= 1) wStartDate = (DateTime)startDates[0];
Label1.Text = wStartDate.ToString("MM/dd/yyyy");
if (endDates.Count >= 1) wEndDate = (DateTime)endDates[endDates.Count - 1];
Label2.Text = wEndDate.ToString("MM/dd/yyyy");
//Label2.Text = tempc;
//Label3.Text = feels;
}
nodes = doc1.SelectNodes(".//j:AssetWarrantyResponse/j:AssetWarrantyResponse/j:AssetHeaderData", nsmgr);
foreach (XmlNode node in nodes)
{
try
{
string custNumber = node["CustomerNumber"].InnerText;
string model = node["MachineDescription"].InnerText;
string orderNumber = node["OrderNumber"].InnerText;
string serialNumber = node["ServiceTag"].InnerText;
Label3.Text = custNumber;
Label4.Text = model;
Label5.Text = orderNumber;
Label6.Text = serialNumber;
}
catch (Exception ex)
{
dbgLabel.Text = ex.Message;
}
}
}
You are looking for AssetWarrantyResponse in namespace http://www.w3.org/2001/XMLSchema-instance (the namespace you have bound to prefix "i") but it is actually in namespace http://schemas.datacontract.org/2004/07/Dell.Support.AssetsExternalAPI.Web.Models.V1.Response. Bind a prefix to that namespace (anything will do, e.g "p") and use that prefix in your query, e.g. p:AssetWarrantyResponse, and similarly for other element names.
I wonder if you are spending too much time trying to look for example code that exactly matches what you want to do, and not enough time studying the underlying concepts of the language so that you can apply them to your own problems. Get some good XML books and read them.
There's another problem with your XPath, which is the "/" at the end of the path. That's invalid syntax. If that's the cause of the error then I'm not very impressed with your XPath processor's diagnostics.

how to edit XML data within SOAP Request using C#?

I would like to edit xml data for one element with in SOAP request in order to send unique SOAP requests.
Following is the example request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:web="http://webservice/">
<soapenv:Header/>
<soapenv:Body>
<web:ca>
<type1>
<ad>2013-07-19</ad>
<name>abcd 13071502</name>
<taker>
<taker>TEST</taker>
<emailAddress>test#test.com</emailAddress>
<name>nameTest</name>
<phoneNo>007007007</phoneNo>
<takerUid>1234</takerUid>
</taker>
</type1>
<type2>4</type2>
<type3>peace</type3>
<type4>test</type4>
</web:ca>
</soapenv:Body>
</soapenv:Envelope>
I would like to change "name" element value from "abcd 13071502" to "abcd ". I was able to extract data from "name" element and edit the value by using following code in C#
System.Xml.XmlTextReader xr = new XmlTextReader(#filePath);
while (xr.Read())
{
if (xr.LocalName == "name")
{
xr.Read();
currentNameValue = xr.Value;
int cnvLen = currentNameValue.Length;
string cnvWOdate = currentNameValue.Substring(0, cnvLen-8);
string newNameValue = cnvWOdate+currTimeDate;
break;
}
}
However, I couldn't figure out how to edit the value and save the file. Any help would be appreciated. Thank you.
Use the XmlDocument class instead of the XmlTextReader class.
System.Xml.XmlDocument xd = new XmlDocument();
xd.Load(#"filepath");
foreach(XmlNode nameNode in xd.GetElementsByTagName("name"))
{
if(nameNode.ParentNode.Name == "type1")
{
string currentNameValue = nameNode.InnerText;
int cnvLen = currentNameValue.Length;
string cnvWOdate = currentNameValue.Substring(0,cnvLen-8);
string newNameValue = cnvWOdate+currTimeDate;
nameNode.InnerText = newNameValue;
}
}
xd.Save(#"newFilePath");
XmlDocument doc = new XmlDocument();
doc.Load("file path");
XmlNode nameNode = doc.SelectSingleNode("/Envelope/Body/ca/type1/name");
string currentNameValue = nameNode != null ? nameNode.InnerText : "name not exist";
int cnvLen = currentNameValue.Length;
string cnvWOdate = currentNameValue.Substring(0, cnvLen-8);
string newNameValue = cnvWOdate+currTimeDate;
nameNode.InnerText = newNameValue; //set new value to tag
To get Value or InnerText of a node, you will have to make sure the node exist. The line string currentNameValue has the format like this:
var variable = condition ? A : B;
It's basically saying that if condition is true, then variable equals A, otherwise, variable equals B.

XML Deserialization of an XDocument is too slow

I have a very strange problem. I have SQL Server database which returns huge chunk of XML. In the middle I have .Net C# code. And at the front I have two projects, one is WCF and the other is Console app (for testing only).
Now when I run the code to get the XML from DB and deserialize it using console app, it runs pretty fast. But when I run the same code through WCF, it takes forever to deserialize the XML. I am sure, DB is not the bottleneck here but the Serializer is.
I am using XmlSerializer. I cannot switch to DataContractSerializer because I have lots of XML Attributes to process.
EDIT:
This is the serialization code in a static class:
public static T DeSerialize(String xml)
{
T dto = default(T);
try
{
XDocument parsedXML = XDocument.Parse(xml);
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.UnknownAttribute += new XmlAttributeEventHandler(serializer_UnknownAttribute);
serializer.UnknownElement += new XmlElementEventHandler(serializer_UnknownElement);
serializer.UnknownNode += new XmlNodeEventHandler(serializer_UnknownNode);
serializer.UnreferencedObject += new UnreferencedObjectEventHandler(serializer_UnreferencedObject);
if (serializer.CanDeserialize(parsedXML.CreateReader()))
{
**--This is where everything gets stuck--**
dto = (T)serializer.Deserialize(parsedXML.CreateReader());
}
}
catch (Exception ex)
{
throw;
}
return dto;
}
Then I have just have a manager, lets say WorkManager which uses this code:
Work work = Serialize<Work>.DeSerialize(xml);
and the above statement is called from Console app and WCF project.
The interface is :
[OperationContract]
[WebInvoke(
Method = "POST",
RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml, BodyStyle = WebMessageBodyStyle.Bare,
UriTemplate = "Work")]
XElement Work(Stream contents);
And the implementation is:
public XElement Work(Stream contents)
{
String xml = new StreamReader(contents).ReadToEnd();
WorkManager workManager = new WorkManager();
workManager.Work(xml);
}
A couple of hints:
Get rid of that try/catch block. It's not doing anything for you, since you always throw;
Don't call CreateReader twice, and use a using block:
using (var reader = parsedXML.CreateReader()) {
if (serializer.CanDeserialize(reader))
{
**--This is where everything gets stuck--**
dto = (T)serializer.Deserialize(reader);
}
}

Resources