我想你的WCF REST入门套件。尝试将WCF REST入门工具包看作只是一个配置为在http环境中轻松设置的WCF服务。为WCF REST入门工具包设置的默认模板旨在用作示例。您将不得不创建自己的签名或使其符合您的需求。
您需要关注的关键部分是.svc文件中的代码(无法双击它,您必须选择打开方式)和[ServiceContract]接口。
在提供的代码中修改[ServiceContract]接口,看起来就像是对于常规的WCF服务。
这是您的需要修改
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceContract]
public partial class LibraryFeed
{
public LibraryFeed()
{
}
/// <summary>
/// Returns an Atom feed.
/// </summary>
/// <returns>Atom feed in response to a HTTP GET request at URLs conforming to the URI template of the WebGetAttribute.</returns>
[WebHelp(Comment = "Gets a list of Books.")]
[WebGet(UriTemplate = "/books/?numItems={numItems}")]
[OperationContract]
public Atom10FeedFormatter GetBooks(int numItems)
{
var books = GetBooks();
List<SyndicationItem> items = GetItems(books, numItems);
SyndicationFeed feed = CreateFeed(items);
WebOperationContext.Current.OutgoingResponse.ContentType = ContentTypes.Atom;
return feed.GetAtom10Formatter();
}
/// <summary>
/// Returns an Atom feed.
/// </summary>
/// <returns>Atom feed in response to a HTTP GET request at URLs conforming to the URI template of the WebGetAttribute.</returns>
[WebHelp(Comment = "Gets a single author.")]
[WebGet(UriTemplate = "/authors/?numItems={numItems}")]
[OperationContract]
public Atom10FeedFormatter GetAuthors(int numItems)
{
var authors = GetAuthors();
List<SyndicationItem> items = GetItems(authors, numItems);
SyndicationFeed feed = CreateFeed(items);
WebOperationContext.Current.OutgoingResponse.ContentType = ContentTypes.Atom;
return feed.GetAtom10Formatter();
}
/// <summary>
/// Returns an Atom feed.
/// </summary>
/// <returns>Atom feed in response to a HTTP GET request at URLs conforming to the URI template of the WebGetAttribute.</returns>
[WebHelp(Comment = "Gets a list of Authors.")]
[WebGet(UriTemplate = "/authors/{id}")]
[OperationContract]
public Atom10FeedFormatter GetAuthor(string id)
{
var author = GetSingleAuthor(id);
WebOperationContext.Current.OutgoingResponse.ContentType = ContentTypes.Atom;
return GetItem(author.GetAtom10Formatter());
}
}
的Atom发布频道我想通了这一点,最终的样本。我试图将模板项目作为我的开发基础,而不仅仅是样本,它们是。我刚刚创建了自己的WCF服务,并重新使用Starter Kit中的扩展库。 – 2009-02-16 14:17:54