WCF syndicationlibrary 템플리트에 OperationContract를 추가하려고 시도하지만 URI 템플리트가 일치하지 않거나 다른 내용이 누락 된 것 같습니다. wcf syndicationlibrary 템플리트에 operationContract를 추가하지 못했습니다.
내가가 발생하지 않습니다 http://myserver:8738/Design_Time_Addresses/SyndicationServiceLibrary2/ShowDocument?url=http://www.test.com기능 showDocument 메소드에 접근하려고 할 때 나는 404 오류가 발생합니다.
도움을 주시면 감사하겠습니다.
IFeed1.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.ServiceModel.Web;
using System.Text;
namespace SyndicationServiceLibrary2
{
// NOTE: If you change the interface name "IFeed1" here, you must also update the reference to "IFeed1" in App.config.
[ServiceContract]
[ServiceKnownType(typeof(Atom10FeedFormatter))]
[ServiceKnownType(typeof(Rss20FeedFormatter))]
public interface IFeed1
{
[OperationContract]
[WebGet(UriTemplate = "*", BodyStyle = WebMessageBodyStyle.Bare)]
SyndicationFeedFormatter CreateFeed();
[OperationContract]
[WebInvoke(UriTemplate = "/ShowDocument?*", BodyStyle = WebMessageBodyStyle.Bare)]
int ShowDocument();
// TODO: Add your service operations here
}
}
Feed1.cs :
는using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.ServiceModel.Web;
using System.Text;
namespace SyndicationServiceLibrary2
{
// NOTE: If you change the class name "Feed1" here, you must also update the reference to "Feed1" in App.config.
public class Feed1 : IFeed1
{
public int ShowDocument()
{
int test = 0;
return test;
}
public SyndicationFeedFormatter CreateFeed()
{
// Create a new Syndication Feed.
SyndicationFeed feed = new SyndicationFeed("Feed Title", "A WCF Syndication Feed", null);
List<SyndicationItem> items = new List<SyndicationItem>();
// Create a new Syndication Item.
SyndicationItem item = new SyndicationItem("An item", "Item content", new Uri("http://myserver:8738/Design_Time_Addresses/SyndicationServiceLibrary2/ShowDocument?url=http://www.test.com"));
items.Add(item);
feed.Items = items;
string query = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters["format"];
SyndicationFeedFormatter formatter = null;
if (query == "atom")
{
formatter = new Atom10FeedFormatter(feed);
}
else
{
formatter = new Rss20FeedFormatter(feed);
}
return formatter;
}
}
}
@Bruno : 당신은 코드 또는 XML을 게시 할 경우, ** ** 그 라인을 강조하고 적절하게 그 라인의 서식 편집기 도구 모음의 "코드"버튼 (101 010)를 사용합니다 (그들을 잘 syntax- 얻으십시오 강조 표시됨) - 감사합니다! –