Serializing Objects in Web Services

Posted on 2006-04-27
Last Modified: 2010-04-16

I am currently experiencing difficulty when returned an arraylist of objects from a web service. I am calling the web service using the web browser, however the xml returned does not contain all the public properties of the objects.

I am returned an arraylist of Question objects, each with a number of public properties one of which is an arraylist of Selection objects. I thought that the web service would automatically serialize the public properties into XML etc. I've been reading up on XMLSerialization but cant seem to understand it all that well.

Any suggestions on returning the XML I want?



Question by:fevster

    Author Comment

    I've basically added the XmlInclude attribute to allow the returning of the different objects and added the XmlElement attribute to the arraylist within the question object.

    However the Xml being returned is

    - <anyType xsi:type="CreditExpertQuestion">
      <Selections />
      <Selections />
      <Selections />

    It doensnt seem to be returning any of the public properties. Any ideas?

    LVL 11

    Accepted Solution

    are your props in Selections read only? i mean, do theyhave both get and set implemented?

    Author Comment

    OMG. I didnt know that one. Just tried it out and it works. Any ideas why they wont output the properties if there readonly? Great answer thanks.
    LVL 11

    Expert Comment

    because it has to work both ways
    i mean: the serialized data has to be deserialized
    and to do that the serializer has to have a way to assign values to properties


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Article by: Najam
    Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now