WCF Service with version
I am new on working with WCF service, I am using ADO.Net Entity Data Model, Name it -> DogModel.edmx. where the Dogs table has ID,Name and Age. It's working fine. but, i wanted to understand the concept behind the version.
Here is code for IDog.cs,
[ServiceContract]
public interface IDog
{
[OperationContract]
Author GetAuthorById(string authorId);
}
[DataContract]
public class DogType
{
bool boolValue = true;
int id = 0;
string name = string.Empty;
int age = 0;
[DataMember]
public int ID
{
get { return id; }
set { id = value; }
}
[DataMember]
public string NAME
{
开发者_运维问答 get { return name; }
set { name = value; }
}
[DataMember]
public int AGE
{
get { return age; }
set { age = value; }
}
}
Here is the code i have placed on Dog.cs,
public class Dog : IDog
{
public Author GetAuthorById(string dogId)
{
using (DogEntities pubs = new DogEntities())
{
DogType d = new DogType();
var dog = (from p in pubs.Dogs
where p.Id == dogId
select p).First();
d.ID = author.ID;
d.NAME = author.Name;
d.AGE = author.Age;
return d;
}
}
}
"If i make a new version of the service then i need to just expose a new end". what does that mean, pls explain?
WCF Versioning is not easy to explain in a couple of lines.
There are a couple of different routes you can take, depending on the changes you make to your service, namely:
- Non-strict versioning
- Semi-strict versioning
- Strict versioning
Michele Leroux Bustamante wrote a great two part series on this issue, check it out here:
- Versioning WCF Services, Part 1
- Versioning WCF Services, Part 2
Another great resource to read up on WCF versioning strategies is MSDN:
http://msdn.microsoft.com/en-us/library/ff384251.aspx
精彩评论