我已经生成了一个简单的Atom 1.0提要,类似于
the example shown on MSDN
.
但是,我没有像示例中那样创建主机并通过控制台应用程序测试feed,而是尝试通过配置创建端点。
我的配置如下:
<system.serviceModel>
<services>
<service
name="MyNamespace.MyService"
behaviorConfiguration="returnFaults">
<endpoint
address=""
binding="basicHttpBinding"
contract="MyNamespace.IMyGenericService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="returnFaults">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
当我运行WCF服务时,我可以访问stock description页,甚至可以使用这个地址作为服务引用。但是,如果我尝试调用返回提要的方法(
http://localhost:SomeVSPort/MyService/GetFeed
),我得到一个没有错误的空白页。在方法中设置断点失败,因为该方法似乎没有被调用。
作为参考,我的服务声明如下:
namespace MyNamespace
{
[ServiceContract]
public interface IMyGenericService
{
[OperationContract]
[WebGet]
Atom10FeedFormatter GetFeed();
}
public class MyService: IMyGenericService
{
public Atom10FeedFormatter GetFeed()
{
SyndicationFeed feed = new SyndicationFeed();
//SimpleEntry is a local class that holds location information in a GeoRSS Simple format.
IList<SimpleEntry> entries = new List<SimpleEntry>()
{
new SimpleEntry() { ID = "1", Point = "45.256 -71.92", Title = "Point 1" },
new SimpleEntry() { ID = "2", Point = "-71.92 45.256", Title = "Point 2" }
};
feed.Items = entries
.Select(e => new SyndicationItem()
{
Content = new XmlSyndicationContent(
"application/xml",
new SyndicationElementExtension(e)),
Title = new TextSyndicationContent(e.Title),
Id = e.ID
});
return new Atom10FeedFormatter(feed);
}
}
}