2010-07-19 3 views
0

REST 기반 서비스를 위해 WCF 4에서 새 WCF 라우팅 서비스를 사용할 수 있습니까? 나는 리버스 프록시와 비슷한 것을 염두에두고있다. 기본적으로 나는 동일한 기본 URL과 포트를 가진 IIS를 통해 공개하고자하는 셀프 호스트 기반의 서비스 목록을 가지고있다. 라우팅은 URL의 마지막 부분에 의해 수행되어야합니다. 나는 WCF 라우팅 서비스에 대해 절대적으로 새로운 것이므로 어리석은 질문이라면 저를 용서해주십시오. 그러나 웹에서 그 정보를 찾을 수는 없습니다. (serivce1/2는 selfhosted 서비스입니다) 나는 이런 식으로 뭔가를 시도.net 4 WCF 라우팅 서비스 + REST

:

<system.serviceModel> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="RoutingBehavior"> 
       <routing routeOnHeadersOnly="false" filterTableName="RoutingTable"/> 
       <serviceDebug includeExceptionDetailInFaults="true"/> 
       <serviceMetadata httpGetEnabled="true"/> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <services> 
     <service behaviorConfiguration="RoutingBehavior" name="System.ServiceModel.Routing.RoutingService"> 
      <endpoint address="myservices" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="basicHttpBinding"/> 
     </service> 
    </services> 
    <routing> 
     <filterTables> 
      <filterTable name="RoutingTable"> 
       <add filterName="service1Filter" priority="0" endpointName="service1"/> 
       <add filterName="service2Filter" priority="0" endpointName="service2"/> 
      </filterTable> 
     </filterTables> 
     <filters> 
      <filter name="service1Filter" filterType="MatchAll"/> 
      <filter name="service2Filter" filterType="MatchAll"/> 
     </filters> 
    </routing> 
    <client> 
     <endpoint address="http://somehost:8888/test/service1" binding="basicHttpBinding" contract="*" name="service1"/> 
     <endpoint address="http://somehost:8732/test/service2" binding="basicHttpBinding" contract="*" name="service2"/> 
    </client> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
</system.serviceModel> 

하지만이 작동하지 않습니다. 예외가 발견되지 않는 엔드 포인트가 나타납니다. http://somehost:8888/test/service1 ist 실제 호스트가 아닌 자체 호스트 서비스의 기본 주소입니다. 기본 주소를 기반으로 라우팅을 수행 할 수 있습니까 (아니면 나머지 라우팅이 가능한 경우) 모든 끝점에 대한 경로를 추가해야합니까?

+0

아마 나는 WCF 라우팅 서비스를 놓쳤을 것이라고 생각합니다. ARR과 같은 "실제"역방향 프록시를 사용하겠습니다. – Jeldrik

답변

1

리버스 프록시 (내 경우에는 arr)를 사용하여 문제를 해결했습니다. 이 목적을 위해 WCF 라우팅 서비스를 사용하는 것이 가능하다면 이해가되지 않지만 오용 될 수 있습니다.

+0

이 좋은 조언을 좀 더 자세히 설명하려면 ARR 확장을 설치 한 다음 iis의 프록시를 사용하여 다른 호스트에 URL 재 작성을 허용 한 다음 wcf 라우팅 서비스 web.config에 다시 쓰기 규칙을 작성하여 두 비누 직선 html은 다소 투명하게 처리됩니다. 내 웹 콘텐츠보다 덜 사소한 웹 콘텐츠의 경우 일부 아웃 바운드 규칙이 필요할 것입니다. – LOAS

1

라우팅 서비스는 SOAP 요청에만 사용할 수 있습니다. RESTful WCF에서 라우팅을 사용하려면 MVC 라우팅과 비슷한 System.Web.Routing을 사용하여 경로를 설정해야합니다.