XML : Xmlns Not pulling information once added to Class

I am currently pulling a httpwebrequest for warranty information. I have tested each section for information and it worked. Once I put it into a class it failed.

My question is, what might I be missing here?:

      Dell computerRequest = new Dell(apiKey);              XDocument xlTest = new XDocument();              xlTest = computerRequest.XmlResponse(txtTag.Text.Trim());                XNamespace getAssetWarrantyA = "http://schemas.datacontract.org/2004/07/Dell.AWR.Domain.Asset";              XNamespace getAssetWarrantyI = "http://www.w3.org/2001/XMLSchema-instance";                List<Device> xlAsset = (from asset in xlTest.Descendants(getAssetWarrantyA + "Reponse")                            select new Device()                            {                                DeviceInfo = (from defaultInfo in asset.Descendants(getAssetWarrantyA + "DellAsset")                                              select new DeviceBase()                                              {                                                  Product = (string)asset.Descendants(getAssetWarrantyA + "MachineDescription").FirstOrDefault(),                                                  OrderNumber = (string)asset.Descendants(getAssetWarrantyA + "OrderNumber").FirstOrDefault(),                                                  ServiceTag = (string)asset.Descendants(getAssetWarrantyA + "ServiceTag").FirstOrDefault(),                                                  ShipDate = (string)asset.Descendants(getAssetWarrantyA + "ShipDate").FirstOrDefault()                                              }).ToList(),                                 WarrantyInfo = (from warranty in asset.Descendants(getAssetWarrantyA + "Warranty")                                                 select new Warranty()                                                 {                                                     Service = (string)warranty.Descendants(getAssetWarrantyA + "ServiceLevelDescription").FirstOrDefault(),                                                     Provider = (string)warranty.Descendants(getAssetWarrantyA + "ServiceProvider").FirstOrDefault(),                                                     StartDate = (string)warranty.Descendants(getAssetWarrantyA + "StartDate").FirstOrDefault(),                                                     EndDate = (string)warranty.Descendants(getAssetWarrantyA + "EndDate").FirstOrDefault(),                                                     TypeOfWarranty = (string)warranty.Descendants(getAssetWarrantyA + "EntitlementType").FirstOrDefault()                                                 }).ToList(),                            }).ToList();        **//FAILS -- No object set to reference**              Device testDevice = new Device();              MessageBox.Show(testDevice.WarrantyInfo.Count.ToString());                dtGrdWar.DataSource = xlAsset.ToArray();                       }            public class Device          {              public List<DeviceBase> DeviceInfo{ get; set; }                          public List<Warranty> WarrantyInfo { get; set; }          }          public class DeviceBase          {              public string Product { get; set; }              public string OrderNumber { get; set; }              public string ServiceTag { get; set; }              public string ShipDate { get; set; }            }          public class Warranty          {              public string Service { get; set; }              public string Provider { get; set; }              public string StartDate { get; set; }              public string EndDate { get; set; }              public string TypeOfWarranty { get; set; }          }    

XML:

  <GetAssetWarrantyResponse xmlns="http://tempuri.org/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">  <GetAssetWarrantyResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:a="http://schemas.datacontract.org/2004/07/Dell.AWR.Domain.Asset">  <a:Faults/>  <a:Response>  <a:DellAsset>  <a:AssetParts i:nil="true"/>  <a:CountryLookupCode>11</a:CountryLookupCode>  <a:CustomerNumber>117731304</a:CustomerNumber>  <a:IsDuplicate>false</a:IsDuplicate>  <a:ItemClassCode>OC002</a:ItemClassCode>  <a:LocalChannel>66</a:LocalChannel>  <a:MachineDescription>COMPELLENT SC8000,1st,2nd,UPG</a:MachineDescription>  <a:OrderNumber>NANANANAN</a:OrderNumber>  <a:ParentServiceTag i:nil="true"/>  <a:ServiceTag>XXXXXXX</a:ServiceTag>  <a:ShipDate>2014-02-07T00:00:00</a:ShipDate>  <a:Warranties>  <a:Warranty>  <a:EndDate>2016-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>933-5366</a:ItemNumber>  <a:ServiceLevelCode>S9</a:ServiceLevelCode>  <a:ServiceLevelDescription>4 Hour On-Site Service</a:ServiceLevelDescription>  <a:ServiceLevelGroup>5</a:ServiceLevelGroup>  <a:ServiceProvider>UNY</a:ServiceProvider>  <a:StartDate>2015-07-31T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2016-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>974-9929</a:ItemNumber>  <a:ServiceLevelCode>ZL</a:ServiceLevelCode>  <a:ServiceLevelDescription>CML - Storage Center Core Base</a:ServiceLevelDescription>  <a:ServiceLevelGroup>11</a:ServiceLevelGroup>  <a:ServiceProvider>DELL</a:ServiceProvider>  <a:StartDate>2015-07-31T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2016-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>933-5406</a:ItemNumber>  <a:ServiceLevelCode>SV</a:ServiceLevelCode>  <a:ServiceLevelDescription>Silver Premium Support</a:ServiceLevelDescription>  <a:ServiceLevelGroup>8</a:ServiceLevelGroup>  <a:ServiceProvider>DELL</a:ServiceProvider>  <a:StartDate>2015-07-31T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2015-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>933-5416</a:ItemNumber>  <a:ServiceLevelCode>SV</a:ServiceLevelCode>  <a:ServiceLevelDescription>Silver Premium Support</a:ServiceLevelDescription>  <a:ServiceLevelGroup>8</a:ServiceLevelGroup>  <a:ServiceProvider>DELL</a:ServiceProvider>  <a:StartDate>2014-08-01T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2015-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>933-5376</a:ItemNumber>  <a:ServiceLevelCode>S9</a:ServiceLevelCode>  <a:ServiceLevelDescription>4 Hour On-Site Service</a:ServiceLevelDescription>  <a:ServiceLevelGroup>5</a:ServiceLevelGroup>  <a:ServiceProvider>UNY</a:ServiceProvider>  <a:StartDate>2014-08-01T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2015-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>975-0042</a:ItemNumber>  <a:ServiceLevelCode>ZL</a:ServiceLevelCode>  <a:ServiceLevelDescription>CML - Storage Center Core Base</a:ServiceLevelDescription>  <a:ServiceLevelGroup>11</a:ServiceLevelGroup>  <a:ServiceProvider>DELL</a:ServiceProvider>  <a:StartDate>2014-08-01T00:00:00</a:StartDate></a:Warranty>  <a:Warranty>  <a:EndDate>2014-07-31T23:59:59</a:EndDate>  <a:EntitlementType>EXTENDED</a:EntitlementType>  <a:ItemNumber>933-5376</a:ItemNumber>  <a:ServiceLevelCode>S9</a:ServiceLevelCode>  <a:ServiceLevelDescription>4 Hour On-Site Service</a:ServiceLevelDescription>  <a:ServiceLevelGroup>5</a:ServiceLevelGroup>  <a:ServiceProvider>UNY</a:ServiceProvider>  <a:StartDate>2014-02-07T00:00:00</a:StartDate></a:Warranty></a:Warranties></a:DellAsset></a:Response></GetAssetWarrantyResult></GetAssetWarrantyResponse>    

No comments:

Post a Comment