I am able to deserialize an array using XMLSerializer but the size of an
array is 0.The problem seems to be because of unqualified element name but I
am not very sure.
Here is what I did:
I get the following xml from the server
================================================== =
<fault xsi:type="FdkException" xmlns="http://xmlns.oracle.com/content/ws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<exceptionEntries soapenc:arrayType="FdkExceptionEntry[1]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<exceptionEntries xsi:type="FdkExceptionEntry">
<detailedErrorCode
xsi:type="xsd:string">ORACLE.FDK.ServerError</detailedErrorCode>
<serverStackTraceId
xsi:type="xsd:string">22-1132729995032</serverStackTraceId>
</exceptionEntries>
</exceptionEntries>
</fault>
================================================== =
I want to deserialize the complex type FdkException which has an array of
FdkExceptionEntry.Definition of the the types are follows
[System.Serializable]
[XmlRootAttribute("fault",
Namespace="http://xmlns.oracle.com/content/ws",IsNullable = false)]
[System.Xml.Serialization.XmlType("FdkException",
Namespace="http://xmlns.oracle.com/content/ws")]
public class FdkException
{
public FdkExceptionEntry[] exceptionEntries;
}
[System.Serializable]
[System.Xml.Serialization.SoapTypeAttribute("FdkExc eptionEntry",
"http://xmlns.oracle.com/content/ws")]
[System.Xml.Serialization.XmlType("FdkExceptionEntr y",
Namespace="http://xmlns.oracle.com/content/ws")]
public class FdkExceptionEntry
{
public string detailedErrorCode;
public string serverStackTraceId;
}
If I change the XML from the server to the following, array is deserialised
perfectly with length 1.
================================================== =
<fault xsi:type="FdkException" xmlns="http://xmlns.oracle.com/content/ws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<exceptionEntries soapenc:arrayType="FdkExceptionEntry[1]"
xsi:type="soapenc:Array"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">
<FdkExceptionEntry>
<detailedErrorCode
xsi:type="xsd:string">ORACLE.FDK.ServerError</detailedErrorCode>
<serverStackTraceId
xsi:type="xsd:string">22-1132729995032</serverStackTraceId>
</FdkExceptionEntry>
</exceptionEntries>
</fault>
================================================== =
Client Code:
System.Xml.Serialization.XmlSerializer ser= new
System.Xml.Serialization.XmlSerializer(typeof(FdkE xception));
FdkException fault= (FdkException)
ser.Deserialize(new System.Xml.XmlTextReader(XMLStream));
XMLStream.Close();
--gaurav