【发布时间】:2009-05-09 03:01:49
【问题描述】:
我想公开一个带有 wcf 和 basicHttpBinding 的 SyndicationFeedFormatter。我继续收到如下所示的错误。我已经包含了接口/类和 web.config wcf 配置。
我曾尝试公开 SyndicationFeedFormatter 以及 IList,但无法克服以下错误。有没有人能够做到这一点或有人确认问题出在哪里?
谢谢 - 戴夫
错误信息
System.ServiceModel.Dispatcher.NetDispatcherFaultException:格式化程序在尝试反序列化消息时抛出异常:尝试反序列化参数http://tempuri.org/:GetFeaturesResult 时出错。 InnerException 消息是“第 1 行位置 123 中的错误。元素“http://tempuri.org/:GetFeaturesResult”包含“http://schemas.datacontract.org/2004/07/System.ServiceModel.Syndication:Rss20FeedFormatter”数据协定的数据
我的界面/合约看起来像
[ServiceContract]
[ServiceKnownType(typeof(Atom10FeedFormatter))]
[ServiceKnownType(typeof(Rss20FeedFormatter))]
public interface IGetData {
[OperationContract]
SyndicationFeedFormatter GetFeatures();
[OperationContract]
IList<SyndicationItem> GetFeatures2();
}
我的方法看起来像......
public SyndicationFeedFormatter GetFeatures()() {
// Generate some items...
SyndicationFeed feed = new SyndicationFeed() {
Title = new TextSyndicationContent("Mike's Feed"),
Description = new TextSyndicationContent("Mike's Feed Description")
};
feed.Items = from i in new int[] { 1, 2, 3, 4, 5 }
select new SyndicationItem() {
Title = new TextSyndicationContent(string.Format("Feed item {0}", i)),
Summary = new TextSyndicationContent("Not much to see here"),
PublishDate = DateTime.Now,
LastUpdatedTime = DateTime.Now,
Copyright = new TextSyndicationContent("MikeT!"),
};
return (new Rss20FeedFormatter(feed));
}
public IList<SyndicationItem> GetFeatures2() {
List<string> includeList = new List<string>();
includeList.Add("Feature");
IList<SyndicationItem> mylist = ReaderManager.GetFeedByCategory2(includeList, null, null);
return mylist;
}
我的 web.config 如下所示
binding="webHttpBinding" contract="SLNavigationApp.Web.IGetData"> -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="webHttpBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="SLNavigationApp.Web.GetDataBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
【问题讨论】:
标签: .net wcf silverlight