user3478233
user3478233

Reputation: 87

WCF service is adding extra word 'Field' to attributes

WCF service is adding extra word 'Field' to attributes. I tried adding System.ServiceModel.XmlSerializerFormatAttribute() but still it adds 'Field' to the attributes. Is there a way i can fix this?

  [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml",  
          "4.0.30319.233")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute()]
  public partial class Employer
  {

      private string nameField;

      [System.Xml.Serialization.XmlElementAttribute(ElementName = "Name")]
      public string Name
      {
         get
         {
            return this.nameField;
         }
         set
         {
            this.nameField= value;
         }
      }

Upvotes: 0

Views: 670

Answers (1)

Jesper Markling
Jesper Markling

Reputation: 26

Add this to your Interface file in the WCF project, and you should prevent it.

  public interface IService
    {

        [System.ServiceModel.XmlSerializerFormatAttribute()]
        [System.ServiceModel.OperationContract] 
        string GetData(int value);
     }

Upvotes: 1

Related Questions