Reputation: 3317
Can someone help me to deserialize that? I tried it with xsd.exe
but the part does not serialize the entries to an array of entry.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:OverrideEntriesRequest xmlns:ns3="urn:Bol:Main:S1:Public" xmlns="urn:Bol:Main:M1:Public" xmlns:ns2="urn:Bol:Main:Public">
<ns3:SessionHeader>
<ns2:AppLogin>user</ns2:AppLogin>
<ns2:AppPassword>password</ns2:AppPassword>
</ns3:SessionHeader>
<ns3:DataCategoryPath>\\Path\\ToData</ns3:DataCategoryPath>
<ns3:Entries>
<Entry>
<EntryName>Key1</EntryName>
<Attributes>
<EntryAttribute>
<Name>Attr1</Name>
</EntryAttribute>
<EntryAttribute>
<Name>Attr2</Name>
<Value>v1</Value>
</EntryAttribute>
<EntryAttribute>
<Name>Attr3</Name>
<Value>V2</Value>
</EntryAttribute>
</Attributes>
</Entry>
<Entry>
<EntryName>Key1</EntryName>
<Attributes>
<EntryAttribute>
<Name>Attr1</Name>
<Value>Val1</Value>
</EntryAttribute>
<EntryAttribute>
<Name>Attr2</Name>
<Value>Val2</Value>
</EntryAttribute>
<EntryAttribute>
<Name>Attr3</Name>
<Value>Val3</Value>
</EntryAttribute>
<EntryAttribute>
<Name>Attr4</Name>
<Value>Val4</Value>
</EntryAttribute>
<EntryAttribute>
<Name>Attr5</Name>
<Value>Val5</Value>
</EntryAttribute>
</Attributes>
</Entry>
</ns3:Entries>
</ns3:OverrideEntriesRequest>
</soapenv:Body>
</soapenv:Envelope>
Upvotes: 0
Views: 593
Reputation: 1915
use this classes to deserialize your xml
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "http://schemas.xmlsoap.org/soap/envelope/", IsNullable = false)]
public partial class Envelope
{
private EnvelopeBody bodyField;
/// <remarks/>
public EnvelopeBody Body
{
get
{
return this.bodyField;
}
set
{
this.bodyField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "http://schemas.xmlsoap.org/soap/envelope/")]
public partial class EnvelopeBody
{
private OverrideEntriesRequest overrideEntriesRequestField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:Bol:Main:S1:Public")]
public OverrideEntriesRequest OverrideEntriesRequest
{
get
{
return this.overrideEntriesRequestField;
}
set
{
this.overrideEntriesRequestField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:Bol:Main:S1:Public")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "urn:Bol:Main:S1:Public", IsNullable = false)]
public partial class OverrideEntriesRequest
{
private OverrideEntriesRequestSessionHeader sessionHeaderField;
private string dataCategoryPathField;
private Entry[] entriesField;
/// <remarks/>
public OverrideEntriesRequestSessionHeader SessionHeader
{
get
{
return this.sessionHeaderField;
}
set
{
this.sessionHeaderField = value;
}
}
/// <remarks/>
public string DataCategoryPath
{
get
{
return this.dataCategoryPathField;
}
set
{
this.dataCategoryPathField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("Entry", Namespace = "urn:Bol:Main:M1:Public", IsNullable = false)]
public Entry[] Entries
{
get
{
return this.entriesField;
}
set
{
this.entriesField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:Bol:Main:S1:Public")]
public partial class OverrideEntriesRequestSessionHeader
{
private string appLoginField;
private string appPasswordField;
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:Bol:Main:Public")]
public string AppLogin
{
get
{
return this.appLoginField;
}
set
{
this.appLoginField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Namespace = "urn:Bol:Main:Public")]
public string AppPassword
{
get
{
return this.appPasswordField;
}
set
{
this.appPasswordField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:Bol:Main:M1:Public")]
[System.Xml.Serialization.XmlRootAttribute(Namespace = "urn:Bol:Main:M1:Public", IsNullable = false)]
public partial class Entry
{
private string entryNameField;
private EntryEntryAttribute[] attributesField;
/// <remarks/>
public string EntryName
{
get
{
return this.entryNameField;
}
set
{
this.entryNameField = value;
}
}
/// <remarks/>
[System.Xml.Serialization.XmlArrayItemAttribute("EntryAttribute", IsNullable = false)]
public EntryEntryAttribute[] Attributes
{
get
{
return this.attributesField;
}
set
{
this.attributesField = value;
}
}
}
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true, Namespace = "urn:Bol:Main:M1:Public")]
public partial class EntryEntryAttribute
{
private string nameField;
private string valueField;
/// <remarks/>
public string Name
{
get
{
return this.nameField;
}
set
{
this.nameField = value;
}
}
/// <remarks/>
public string Value
{
get
{
return this.valueField;
}
set
{
this.valueField = value;
}
}
}
and use the below code to deserialize
XmlSerializer deserializer = new XmlSerializer(typeof(Envelope));
TextReader reader = new StreamReader(@"D:\1.xml");
object obj = deserializer.Deserialize(reader);
Envelope XmlData = (Envelope)obj;
reader.Close();
Hope this helps.
Upvotes: 1