【发布时间】:2010-07-19 13:22:38
【问题描述】:
是否可以将 WCF 4 中的新 WCF 路由服务用于基于 REST 的服务?我想到了类似于反向代理的东西。基本上,我有许多基于自托管的基于休息的服务,我想通过具有相同基本 url 和端口的 IIS 公开这些服务。路由应该由 url 的最后一部分完成。我对 thw 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 是自托管服务的基地址,而不是实际端点。我可以根据基地址进行路由吗?或者(如果可以使用其他路由)我必须为每个端点添加路由吗?
【问题讨论】:
-
我认为这可能会误用 WCF 路由服务。我将使用像 ARR 这样的“真正的”反向代理。
标签: wcf