I want to send a http request from client to local server and on the server I made a query with Linq that returns data in xml I also have .xsd file and a .cs file enerated from my xsd file that I want to validate my xml with. I have several questions:
how can I validate xml with c# generated class?
how can I return xml from server to client?
this is my c# class:
using System.Xml.Serialization;
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class FlashList {
private FlashListFlash flashField;
public FlashListFlash flash {
get {
return this.flashField;
}
set {
this.flashField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.17929")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class FlashListFlash {
private string vinField;
private string modelTypeField;
public string Vin {
get {
return this.vinField;
}
set {
this.vinField = value;
}
}
public string ModelType {
get {
return this.modelTypeField;
}
set {
this.modelTypeField = value;
}
}
}
and this is my XML format:
<FlashList>
<flash>
<Vin>aa123654654s6546</Vin>
<ModelType>x23j</ModelType>
</flash>
</FlashList>
and this is my main file that I made the query:
namespace WebApplication1
{
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class MyWebService : System.Web.Services.WebService
{
[WebMethod]
public XXX MyService(string vinValue)
{
FlashListFlash flash = new FlashListFlash();
LinqSqlDataContext db = new LinqSqlDataContext();
var reportdata = from Vin in db.Vin
from Global in db.Globals
from Associate in db.Associas
where Vin.Vin == vinValue && Vin.NHard == Global.NHard &&
Global.NomeFile == Associate.KeyJoined &&
SqlMethods.Like(Global.NVerHard, "0" + Vin.NVerHard)
select new XElement("flash",
new XElement("Vin", Vin.Vin),
new XElement("ModelType", Associate.Model_Type)
);
XElement reportXml = new XElement("FlashList", reportdata);
string fileName = @"D:\FlashList.xml";
Directory.CreateDirectory(Path.GetDirectoryName(fileName));
reportXml.Save(fileName);
return XXX;
}
}
}