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을 좀더 융통성있게 계약해야하기 때문이다. 예를 들어 카테고리 별 반환 목록이 필요한 경우 (예 : localhost/rest/category/2). 하지만이 uri 및 현재 구성 (주소 속성이, web.config)에서이 메소드를 범주 계약에 넣어야합니다. 그러나 내 의견으로는이 약물은 영화 계약에 있어야합니다. 그렇다면 해결책이 있거나 정상입니까?