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("FdkExceptionEntry",
"http://xmlns.oracle.com/content/ws")]
[System.Xml.Serialization.XmlType("FdkExceptionEntry",
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(FdkException));
FdkException fault= (FdkException)
ser.Deserialize(new System.Xml.XmlTextReader(XMLStream));
XMLStream.Close();
--gaurav
DC - 30 Nov 2005 19:25 GMT
The two XML snippets - the before and after - are exactly the same?
You said "If I change the XML to... <blah>... then it works."
But that <blah> is the same as the original XML.
Care to amend your post?
-D
D i n o . C h i e s a AT M i c r o s o f t . c o m
>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
[quoted text clipped - 82 lines]
>
> --gaurav