I need to modify an existing method of web services to include additional data member (Like add category attribute to email object).
The problem is, the web service method has already been used by a number of applications. This additional attribute will only be beneficial to one new application that I am working on, it should not have any effects on any one of these existing application.
Is there any attribute that I can use to set this new field to be optional for the applications that consume it? Without breaking any existing applications.
Here is code Snippet for the webservice:
[DataContract(Namespace = "URN:SmartmailPRO")]
public class Email : IEmail, IValidDataContract
{
[DataMember(IsRequired = false, Order = 1)]
public int EmailId { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public int CampaignFolderId { get; set; }
/*I want to add this attribute to the class definition, but I am not sure whether this will break any existing application that consumes the web services.*/
//[DataMember(IsRequired = false, Order = 1)]
//public string CampaignFolderName { get; set; }
[DataMember(IsRequired = true, Order = 1)]
public int ListId { get; set; }
[DataMember(IsRequired = true, Order = 1)]
public int FromAddressId { get; set; }
[DataMember(IsRequired = true, Order = 1)]
public int ReplyAddressId { get; set; }
[DataMember(IsRequired = true, Order = 1)]
public string EmailName { get; set; }
[DataMember(IsRequired = true, Order = 1)]
public string FromName { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public string HTMLContent { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public string TextContent { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public string Subject { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public string CustomData { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public bool Sent { get; set; }
[DataMember(IsRequired = false, Order = 1)]
public int TemplateId { get; set; }
[DataMember(IsRequired = false, Order = 2)]
public DateTime? SentDateUTC { get; set; }
.....
}
Here is code Snippet for how to consume the webservice:
var results = ApiHelper.EmailSearch(new EmailQuery()
{
ListId = 1711,
//QA_CAMPAIGN_FOLDER
Status = 1,
StatusFrom = Convert.ToDateTime("01/01/2013"),
StatusTo = Convert.ToDateTime("01/01/2014")
});
this.dataGridView1.DataSource = results;
I have developed two testing windows form applications to consume the web services. First one consumes the original web services. Second one consumes the modified web services. After I added the additional property to the Email class, both windows form application work fine.