是否可以使用WCF 4中新的WCF路由服务来提供基于REST的服务?我有一个类似于反向代理的想法。基本上,我有许多基于rest的自托管服务,我想通过IIS使用相同的基本url和端口公开这些服务。路由应该由url的最后一部分完成。我对WCF路由服务完全陌生,所以如果这是个愚蠢的问题,请原谅我,但是我在网上找不到任何关于这个的信息。
我尝试过类似的方法(serivce1/2是自托管服务):
<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是自托管服务的基址,而不是实际的终结点。我可以基于基址进行路由吗?或者(如果rest路由是可能的)我必须为每个端点添加一个路由吗?