tags:

views:

179

answers:

1

Is it possible to use the new WCF routing serice in WCF 4 for REST based services? I have something similar to a reverse proxy in mind. Basically I have a number of selfhosted rest based serivces which I want to expose via IIS with the same base url and port. The routing should be done by the last part of the url. I'm absolutly new to thw WCF routing service, so forgive me if that's a silly question, but I couldn't find any information about that on the web.

I have tried something like this (where serivce1/2 are the selfhosted services):

<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>

but that doesn't seem to work. I'm getting an endpoint not found exception. http://somehost:8888/test/service1 ist the base address of the selfhosted service and not the actual endpoint. Can I do routing based on the base address or (if rest routing is possible) must I add a route for every endpoint?

A: 

I solved the problem by using a reverse proxy (in my case arr). I don't konw if using the WCF routing service for this purpose is possible, but it's probably a misuse.