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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:19:06+00:00 2026-05-15T16:19:06+00:00

I have a WCF service that uses Message contract for request and replies of

  • 0

I have a WCF service that uses Message contract for request and replies of data.
This is the service contract :

 [ServiceContract()]
 public interface ISalesFinderService
 {
     [OperationContract()]
     Response DoSomething(Request i_Info);
 }

The problem occurs when the service returns a response. This is the Response Message:

[MessageContract()]
public class ObjectInfo
{
    [MessageBodyMember(Name = "Name")]
    public string  m_Name;
}

[MessageContract()]
public class Response
{
   private List<ObjectInfo> m_MyListOfObjects;

   public FindSalesByLocationInfoMessageResponse()
   {
       m_MyListOfObjects = new List<ObjectInfo>();
   }

   [MessageBodyMember(Name = "ObjectsInfo")]
   public List<ObjectInfo> MyListOfObjects
   {
            get { return m_MyListOfObjects;  }
            set { m_MyListOfObjects = value; }
   }
}

When the response comes out I can see (through wireshark) that all the fields inside the list (of type ObjectInfo) were serialized to XML and got the tag <a:m_Name></a:m_Name>
although I added specifically MessageBodyMember attribute above the m_Name data member and gave it “Name” as it’s tag.

How can I change those tags names as I wish ???

thanks..

  • 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-15T16:19:06+00:00Added an answer on May 15, 2026 at 4:19 pm

    I think you’re misunderstanding the reason for the message contract and how to use it. Check out the MSDN documentation on Using Message Contracts for a more thorough discussion.

    The message contract allows you to define a layout of your message with header(s) and body elements. Those can be atomic types like string or int, and if not, you need to define composite types as classes.

    Those composite parts (classes) that you use in that message contract ought to be marked as [DataContract] with [DataMember] attributes on the individual fields you want to serialize.

    Furthermore, your message contract and data contracts should never contain any functions and anything that needs to execute. The data structures will be serialized as data only, any behavior will be lost in the transfer.

    So in your case, you should try:

    [MessageContract()]
    public class Response
    {
        private List<ObjectInfo> m_MyListOfObjects = new List<ObjectInfo>();
    
        [MessageBodyMember(Name = "ObjectsInfo")]
        public List<ObjectInfo> MyListOfObjects
        {
            get { return m_MyListOfObjects;  }
            set { m_MyListOfObjects = value; }
        }
    }
    
    [DataContract]
    public class ObjectInfo
    {
        [DataMember(Name = "Name")]
        public string m_Name;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Data Service created using WCF that internally uses nHibernate. This WCF
I have a wcf service that uses the WsHttpBinding as a binding. This service
I have WCF service that uses wsHttpBinding and authentication with certificate. I run this
This issue is driving me crazy. I have a WCF service that uses a
I have a WCF service that uses transport and message security. How do i
I have a wcf service that uses the .net System.AddIns framework to load assemblies
I have an wcf service that is hosted in II6. The service uses the
I have a WCF service that is deployed on a machine. This WCF service
I have a wcf service that uses callbacks with DualHttpBindings. The service pushes back
I have silverlight 2.0 application and which uses WCF service to get data and

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.