0

SyndicationFeedをクライアントとしてロードするための単純なWCFラッパーを作成しようとしています。

契約

[ServiceContract]
public interface IFeedService
{
    [OperationContract]
    [WebGet(UriTemplate="")]
    SyndicationFeed GetFeed();
}

使用法

using (var cf = new WebChannelFactory<IFeedService>(new Uri("http://channel9.msdn.com/Feeds/RSS")))
{
    IFeedService s = cf.CreateChannel();
    this.FeedItemsList.DataSource = s.GetFeed().Items;
}

質問問題は、サービスがURLにメソッド名を追加していることです(つまり、上記のURLはhttp://channel9.msdn.com/Feeds/RSS/GetFeedを呼び出します)。これを任意のURLに拡張したいのでフィードフィードの名前はいつもわかりません。メソッド名を追加する代わりにデフォルトのエンドポイントアドレスを使用するように指定できる属性またはプロパティはありますか?

更新 [WebGet(UriTemplate = "")]を追加すると、途中でしか取得できません。http://channel9.msdn.com/Feeds/RSSで機能し、 http://channel9.msdn.com/Feeds/RSS/に変更されますが、 http://weblogsなどの他のフィードでは機能しません。 .asp.net / scottgu / atom.aspxは、 http: //weblogs.asp.net/scottgu/atom.aspx/に変更されます。

4

2 に答える 2

0

WebGetAttribute の UriTemplate を空の文字列に変更すると、それができると思います。

http://msdn.microsoft.com/en-us/library/system.servicemodel.web.webgetattribute.uritemplate.aspx

于 2008-12-16T20:00:29.157 に答える
0

OperationContext/WebOperationContext を使用してそれを行う方法があると思います。正確な詳細は忘れましたが、たとえば、チャネルに OperationContextScope を作成するこの例を参照してください

http://social.msdn.microsoft.com/forums/en-US/wcf/thread/8f9f276a-e13f-4d06-8c1e-0bb6abd8f5fe

たとえば、OperationContext.Current.OutgoingMessageProperties (.Via を目的の Uri に設定)、または WebOperationContext.Current.OutgoingWebRequest (HTTP ヘッダーまたは「メソッド」(http 動詞) など) を設定する場合などにアクセスできます。 . OperationContext.Current.OutgoingMessageProperties.Via を突き刺すと、必要なことを実行できると思います。

于 2008-12-17T15:14:08.017 に答える