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

  • SEARCH
  • Home
  • 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 8744807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:54:08+00:00 2026-06-13T11:54:08+00:00

I am getting the following response from a standard MVC 4 WebApi project; <ArrayOfProduct

  • 0

I am getting the following response from a standard MVC 4 WebApi project;

<ArrayOfProduct xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Product>
<Id>1</Id>
<Name>Tomato Soup</Name>
<Category>Groceries</Category>
<Price>1</Price>
</Product>
</ArrayOfProduct>

I am trying to make it so that it returns

<Products>
<Product>
<Id>1</Id>
<Name>Tomato Soup</Name>
<Category>Groceries</Category>
<Price>1</Price>
</Product>
</Products>

I have found many reference to various methods that supposedly solve this, none work;

Changing the default serializer does not work.

Creating a customer serializer for Product does not work.

Creating a new class that has List<Product> exposed with suitable XmlRoot and XmlElement attributes does not work.

Adding Datacontract attributes does not work.

Adding CollectionDatacontract attributes does not work.

This appears to be so simple to everyone else, except me!

  • 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-13T11:54:08+00:00Added an answer on June 13, 2026 at 11:54 am

    Try using the XmlSeriazlier instead:

    config.Formatters.XmlFormatter.UseXmlSerializer = true;
    

    And then try defining a class that derives from the collection of Product, and use [XmlRoot(“Products”)] to rename the element name from ‘ArrayOfProduct’ to ‘Products’.

    For example, instead of using List, use the class Products:

    [XmlRoot("Products")]
    public class Products : List<Product> { }
    
    public class Product
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Category { get; set; }
        public double Price { get; set; }
    }
    

    ApiController’s action:

        public Products Get()
        {
            return new Products()
            {
                new Product() 
                {
                    Id = 1,
                    Name = "Tomato Soup", 
                    Category = "Groceries",
                    Price = 1
                }
            };
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Following up on this question: Getting raw XML response from Java web service client
I am getting the following response from server: <?xml version=1.0 encoding=UTF-8?> <tracks type=array> <track>
friends, i am getting following webservice response from dotnet service. <Bank> <bankID>1</bankID> <bankName>AIK Banka</bankName>
I am getting back the following response from a charge-amount-notification. (in the sandbox env).
I'm getting the following JSON response from the server: [{id:1,pid:0,type:Individual,code:i,status:1}, {id:2,pid:0,type:Group,code:g,status:1}, {id:15,pid:0,type:asdasd,code:asd,status:1}, {id:16,pid:0,type:asdas,code:asd,status:1}, {id:17,pid:0,type:my
I am new to WebService. I am getting the following response from the WebService
I'm getting a following response from the back-end servers to display the data as
I am getting following response generated from the server by cakephp [ { id:
Let's say you're getting the following response from an API call: [OrderArray] => SimpleXMLElement
Getting the following exception on a response from a JAVA based service (test harness

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.