1
我已經用WCF創建了REST服務,並且我有不同的合同(Contract1,Contract2等)。 這是web.config
如何爲多個端點共享相同的地址
<endpoint address="users" binding="webHttpBinding" behaviorConfiguration="web" contract="FilmInfoApi.Service.IUserService"/>
<endpoint address="actors" binding="webHttpBinding" behaviorConfiguration="web" contract="FilmInfoApi.Service.IActorService"/>
<endpoint address="films" binding="webHttpBinding" behaviorConfiguration="web" contract="FilmInfoApi.Service.IFilmService"/>
配置這是合同的例子。
[OperationContract]
[WebGet(UriTemplate = "?offset={offset}&count={count}", ResponseFormat = WebMessageFormat.Json)]
Films GetFilms(string offset, string count);
所以我的問題是我如何使用相同的地址爲所有端點(本地主機/休息)。因爲我需要合同UriTemplate更靈活,例如,如果我需要根據類別返回電影列表(例如:本地主機/休息/類別/ 2)。但是,通過此uri和當前配置(地址屬性 in web.config),我必須將此方法放入類別合同。但在我看來,這個方法必須在電影合約中。那麼它有解決方案還是正常的?