locked
ASP .NET Webservice Add New Field to the Request without affecting the existing customers RRS feed

  • Question

  • User-372693909 posted

    Hi,

    Request all to advise on best way to "Add New Field in the Request of Webservice without affecting the existing customers."

    I had done like below. Is it proper way?

    [DataMember]

     [XmlElement(IsNullable = true)]

      public string TokenNo { set; get; }

    Thanks in advance for support and time.

    Wednesday, July 3, 2013 2:23 PM

Answers

  • User220959680 posted

    Add New Field in the Request of Webservice without affecting the existing customers."

    WCF will gracefully handle new members that it doesn't recognize. The consumer of the contract (on either the client or the server side) simply won't "see" that member, therefore a consequence is that the new member should never be an IsRequired=true property.

    Furthermore, WCF will transparently bridge the new property between components as long as the DataContract implements IExtensibleDataObject

    consider Data contract versioning

    Best practices: Data contract versioning

    [DataMember]

     [XmlElement(IsNullable = true)]

      public string TokenNo { set; get; }

    [DataMember(IsRequired=False)]
    [XmlElement(IsNullable = true)]
    public string TokenNo { set; get; }



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 5:54 PM

All replies

  • User-1583800459 posted

    The way you described, you can do it in that way or else if you want to give any default value for the TokenNo, you can do it in following way:

    private string _TokenNo = "test";
    
    public string TokenNo
    {
      get
      {
        return _TokenNo;
      }
      set
      {
        _TokenNo = value;
      }
    }


    I hope it will help you. :)

    Thursday, July 4, 2013 1:32 AM
  • User220959680 posted

    Add New Field in the Request of Webservice without affecting the existing customers."

    WCF will gracefully handle new members that it doesn't recognize. The consumer of the contract (on either the client or the server side) simply won't "see" that member, therefore a consequence is that the new member should never be an IsRequired=true property.

    Furthermore, WCF will transparently bridge the new property between components as long as the DataContract implements IExtensibleDataObject

    consider Data contract versioning

    Best practices: Data contract versioning

    [DataMember]

     [XmlElement(IsNullable = true)]

      public string TokenNo { set; get; }

    [DataMember(IsRequired=False)]
    [XmlElement(IsNullable = true)]
    public string TokenNo { set; get; }



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 4, 2013 5:54 PM