Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2005

Tip: Looking for answers? Try searching our database.

deserializing arrays of complex types

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GAURAV KRISHNA - 26 Nov 2005 13:29 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.