deserialize xml array with namespace



I need to deserialize this xml



<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:xsi="http://ift.tt/ra1lAU" SOAP-ENV:encodingStyle="http://ift.tt/wEYywg" xmlns:SOAP-ENV="http://ift.tt/sVJIaE" xmlns:xsd="http://ift.tt/tphNwY">
<SOAP-ENV:Body>
<ns1:estraiListaAttiFascicoloResponse xmlns:ns1="urn:BEAFascicoloInformatico-distr">
<return xmlns:ns2="http://ift.tt/wEYywg" xsi:type="ns2:Array" ns2:arrayType="ns1:BEADocumentoFascicoloVO[2]">
<item xsi:type="ns1:BEADocumentoFascicoloVO">
<annoFascicolo xsi:type="xsd:string">1998</annoFascicolo>
</item>
<item xsi:type="ns1:BEADocumentoFascicoloVO">
<annoFascicolo xsi:type="xsd:string">1998</annoFascicolo>
</item>
</return>
</ns1:estraiListaAttiFascicoloResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


i have tried with this classes:



[XmlType(AnonymousType = true, Namespace = "http://ift.tt/sVJIaE")]
[XmlRoot(Namespace = "http://ift.tt/sVJIaE", IsNullable = false)]
public class Envelope
{
public EnvelopeBody Body { get; set; }

[XmlAttribute(Form = XmlSchemaForm.Qualified)]
public string encodingStyle { get; set; }
}

[XmlType(AnonymousType = true, Namespace = "http://ift.tt/sVJIaE")]
public class EnvelopeBody
{
[XmlElement(Namespace = "urn:BEAFascicoloInformatico-distr")]
public estraiListaAttiFascicoloResponse estraiListaAttiFascicoloResponse { get; set; }
}

/// <remarks/>
[XmlType(AnonymousType = true, Namespace = "urn:BEAFascicoloInformatico-distr")]
[XmlRoot(Namespace = "urn:BEAFascicoloInformatico-distr", IsNullable = false)]
public class estraiListaAttiFascicoloResponse
{
[XmlElement(Namespace = "")]
public @return @return { get; set; }
}

[XmlType(AnonymousType = true)]
[XmlRoot(Namespace = "", IsNullable = false)]
public class @return
{
[XmlElement("item")]
public returnItem[] item { get; set; }

[XmlAttribute(Form = XmlSchemaForm.Qualified, Namespace = "http://ift.tt/wEYywg")]
public string arrayType { get; set; }
}

[XmlType(AnonymousType = true)]
public class returnItem
{
public ushort annoFascicolo { get; set; }
}


and this code



var serializer = new XmlSerializer(typeof(Envelope));

var sw = new StringReader(xmlText);

using (var xmlTextReader = XmlReader.Create(sw))
{
var converted = serializer.Deserialize(xmlTextReader);
}


but i receive this error at runtime


Additional information: There is an error in XML document (5, 5).


and the inner exception in this


The specified type was not recognized: name='Array', Namespace='http://ift.tt/wEYywg', at .


but if i add the namespace "http://ift.tt/wEYywg" to @return property of estraiListaAttiFascicoloResponse class the exception disappears but don't deserialize array items anyway


Can someone help me?


Thanks


No comments:

Post a Comment