Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7778947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:31:35+00:00 2026-06-01T18:31:35+00:00

I have a simple WCF service which has a method that returns a complex

  • 0

I have a simple WCF service which has a method that returns a “complex” object (made up of simple and collection properties). When I call this method and look at the resulting XML, the values are missing for the items in the collection; however, if I examine the .net object in the debugger, the collection and its’ values are populated correctly.

The class containing the collection:


[DataContract]
    public class MetadataResponse
    {
        [DataMember]
        public int index;
        [DataMember]
        public int count;
        [DataMember]
        public int total;
        [DataMember]
        public MediaCollection[] mediaCollection;
        [DataMember]
        public MediaMetadata[] mediaMetadata;
    }

The contained item class:


[DataContract]
    public class MediaCollection
    {
        public String id;
        public String title;
        public Enum itemType;
        public String artistId;
        public String artist;
        public String albumArtURI;
        public Boolean canPlay;
        public Boolean canEnumerate;
        public Boolean canAddToFavorites;
        public Boolean canScroll;
        public Boolean canSkip;
    }

The method that returns the object:


public MetadataResponse getMetadata(string id, int index, int count, bool recursive)
        {
            MetadataResponse metadataResponse = new MetadataResponse();
            MediaCollection mediaCollectionItem = new MediaCollection();

            // return a static collection for now
            metadataResponse.index = 0;
            metadataResponse.count = 3;
            metadataResponse.total = 3;
            metadataResponse.mediaCollection = new MediaCollection[3];

            // add some items
            mediaCollectionItem.id = "0001";
            mediaCollectionItem.title = "foo";
            metadataResponse.mediaCollection[0] = mediaCollectionItem;

            mediaCollectionItem.id = "0002";
            mediaCollectionItem.title = "bar";
            metadataResponse.mediaCollection[1] = mediaCollectionItem;

            mediaCollectionItem.id = "0003";
            mediaCollectionItem.title = "choo";
            metadataResponse.mediaCollection[2] = mediaCollectionItem;

            return metadataResponse;
        }

Debugger result examining the populated object:


{MurfieSoapApi.MetadataResponse}
    count: 3
    index: 0
    mediaCollection: {MurfieSoapApi.MediaCollection[3]}
    mediaMetadata: null
    total: 3

The XML result from the method call (still trying to figure out how to get StackOverflow to format this one…):

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
    <s:Header />
    <s:Body>
        <getMetadataResponse xmlns="http://www.sonos.com/Services/1.1">
            <getMetadataResult xmlns:a="http://schemas.datacontract.org/2004/07/MurfieSoapApi" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
                <a:count>3</a:count>
                <a:index>0</a:index>
                <a:mediaCollection>
                    <a:MediaCollection />
                    <a:MediaCollection />
                    <a:MediaCollection />
                </a:mediaCollection>
                <a:mediaMetadata i:nil="true" />
                <a:total>3</a:total>
            </getMetadataResult>
        </getMetadataResponse>
    </s:Body>
</s:Envelope>

I have tried other collection types instead of arrays (List, etc.) but the results were always the same. I’m using the default web.config values which has worked well for other methods which return simple results, but maybe the automatic mapper isn’t up to the task when it comes to this return type…not sure.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:31:36+00:00Added an answer on June 1, 2026 at 6:31 pm

    Because you are missing the

    DataMember

    attributes from the MediaCollection class.

    Instead of this:

    [DataContract]
        public class MediaCollection
        {
            public String id;
            public String title;
            public Enum itemType;
            public String artistId;
            public String artist;
            public String albumArtURI;
            public Boolean canPlay;
            public Boolean canEnumerate;
            public Boolean canAddToFavorites;
            public Boolean canScroll;
            public Boolean canSkip;
        }
    

    You should write this:

    [DataContract]
        public class MediaCollection
        {
            [DataMember]
            public String id;
    
            [DataMember]
            public String title;
    
         ....
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple WCF service which accept some data (wsHttpBiding) and returns a
I've have a WCF service which has multiple clients that it connects to. What
We have a simple WCF service that is tagged with InstanceContextMode = Single and
I have written a simple WCF service that accepts and stores messages. It works
I have written a very simple WCF service, that worked fine (code below), then
i have a simple xml file in a wcf service that i am trying
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat
I have a Windows WCF serivce and Web client. My service has one method
We have a simple ASP.Net WCF Ajax enabled web service which is called via
I have created a WCF service, now this WCF service has to call a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.