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 4596906
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:10:54+00:00 2026-05-21T23:10:54+00:00

I send XML to my webservice and the receiving method is: public XElement SubmitRecipe(Recipe

  • 0

I send XML to my webservice and the receiving method is:

public XElement SubmitRecipe(Recipe recipe)

The recipe parameter is correctly receiving all properties but recipe.Allergies has a count of 0, does anyone know why?

Sample XML file:

<Recipe>
<Allergies>
    <Allergy>nuts</Allergy>
    <Allergy>wheat</Allergy>
</Allergies>
<Title>recipe title</Title>
<Id>107</Id>
</Recipe

The Recipe object:

[CollectionDataContract(Name = "Allergies", ItemName = "Allergy")]
public class AllergyList : List<string> { }

[DataContract]
public class Recipe
{        
    [DataMember(Name = "Allergies")]
    public AllergyList Allergies { get; set; }

    [DataMember]
    public int Id { get; set; }

    [DataMember]
    public string Title { get; set; }
}

In my create method test I get what I expect:

public Recipe GetRecipe()
{
    Recipe recipe = new Recipe();

    recipe.Id = 1;
    recipe.Allergies = new AllergyList();
    recipe.Allergies.Add("nuts");
    recipe.Allergies.Add("wheat");
}

<Recipe>
    <Allergies>
        <a:Allergy>nuts</a:Allergy>
        <a:Allergy>wheat</a:Allergy>
    </Allergies>
    <Id>1</Id>
</Recipe>
  • 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-05-21T23:10:55+00:00Added an answer on May 21, 2026 at 11:10 pm

    You may be having an XML Namespace (not .NET namespace) problem with your service contracts. The test example you show has the “a:Allery” element to refer to the collection items. While the sample XML doesn’t contain the “a:” XML namespace alias. I almost always set the Namespace for all the service, operation and data contracts. Yes, it can tedious to do this but the payoff is that you will not have any XML namespace problems and it will definitely help with data contract versioning down the road. Here is what your contract would look like:

    [CollectionDataContract(Name = "Allergies", ItemName = "Allergy",
        Namespace="http://yourorg.co.uk/2011/05/Medical")]
    public class AllergyList : List<string> { }
    
    [DataContract(Namespace="http://yourorg.co.uk/2011/05/Medical")]
    public class Recipe
    {        
        [DataMember(Name = "Allergies")]
        public AllergyList Allergies { get; set; }
    
        [DataMember]
        public int Id { get; set; }
    
        [DataMember]
        public string Title { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to send an XML document over the wire but receiving the following
i have webservice with one method which recieves xml as string: [WebMethod] public int
how to send parameter as arrays in webservice in c#? public xmlElement insertPurchase(string[] txtproductCode,
I am receiving xml from a webservice call that contains a nil=true : <cacheEntry>
I want to pass an XmlDocument as a parameter to my webservice method. After
I'm trying to send by POST method a XML through of CURL to authenticated
I'm tryng to send an request to Cielo's webservice, but if i send with
I want to parse xml webservice in my phonegap application but i don't have
So I have to setup a webservice. Basically, we send X509 signed XML files
In Javascript I can send XML string to JSP server (XmlAction.jsp): Javascript Code: var

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.