Reputation: 1107
I want create routing WCF Service on IIS that will call two other my services on IIS:
First and second service works good if I call them in browser:
http://jobwcf1.evgeny.net/JobWCF.svc/Test
http://jobwcf2.evgeny.net/JobWCF.svc/Test
But when I call throught routing service, it does not work (HTTP 404) (in browser):
http://jobwcfrouter.evgeny.net/JobWCF.svc/Test
web.config of router service:
<system.serviceModel>
<services>
<service name="System.ServiceModel.Routing.RoutingService" behaviorConfiguration="MyBehavior">
<host>
<baseAddresses>
<add baseAddress="http://JobWCFRouter.evgeny.net/JobWCF.svc"/>
</baseAddresses>
</host>
<!-- work through http in browser -->
<endpoint address=""
behaviorConfiguration="web"
binding="webHttpBinding"
bindingConfiguration="HttpBinding"
/>
</service>
</services>
<client>
<endpoint address="http://JobWCF1.local.net/JobWCF.svc" binding="webHttpBinding"
contract="*" name="myEndpoint1" />
<endpoint address="http://JobWCF2.local.net/JobWCF.svc" binding="webHttpBinding"
contract="*" name="myEndpoint2" />
</client>
<routing>
<filters>
<filter name="myEndpointFilter" filterType="MatchAll" />
</filters>
<filterTables>
<filterTable name="RoutingTable">
<add filterName="myEndpointFilter" endpointName="myEndpoint1" backupList="BackUps" />
</filterTable>
</filterTables>
<backupLists>
<backupList name="BackUps">
<add endpointName="myEndpoint2"/>
</backupList>
</backupLists>
</routing>
<bindings>
<webHttpBinding>
<binding name="HttpBinding" sendTimeout="00:15:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" crossDomainScriptAccessEnabled="true">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>
<security mode="None"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyBehavior">
<routing filterTableName="RoutingTable" />
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
Also in router service I have filer Router.svc where is code:
<%@ ServiceHost Language="C#" Debug="true"
Service="System.ServiceModel.Routing.
RoutingService, System.ServiceModel.Routing,
version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
%>
What am I doing wrong?
Upvotes: 1
Views: 764
Reputation: 3964
This may be because you did not start the RoutingService instance. If using self-hosting, we need to use ServiceHost to start RoutingService:
ServiceHost RoutingService= new ServiceHost(typeof(RoutingService));
RoutingService.Open();
If deployed in IIS, you need to add the svc file, and add the following code in the svc file:
<%@ ServiceHost Service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
The host node is not required for deployment in IIS, and the base address of the route is determined by the binding deployed in IIS.
This is my web.config:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
<httpRuntime targetFramework="4.7.2"/>
</system.web>
<system.serviceModel>
<services>
<service name="System.ServiceModel.Routing.RoutingService" behaviorConfiguration="svbhv">
<endpoint name="routing_ep1" address="rout1" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="basicHttpBinding" ></endpoint>
<endpoint name="routing_ep2" address="rout2" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="basicHttpBinding" ></endpoint>
<endpoint name="routing_ep3" address="rout3" contract="System.ServiceModel.Routing.IRequestReplyRouter" binding="basicHttpBinding" ></endpoint>
</service>
</services>
<client>
<endpoint name="calc_sv1" address="http://127.0.0.1:3211" binding="basicHttpBinding" contract="*"></endpoint>
<endpoint name="calc_sv2" address="http://127.0.0.1:3212" binding="basicHttpBinding" contract="*"></endpoint>
</client>
<routing>
<filters>
<filter name="f1" filterType="EndpointName" filterData="routing_ep1"/>
<filter name="f2" filterType="EndpointName" filterData="routing_ep2"/>
<filter name="f3" filterType="EndpointName" filterData="routing_ep3"/>
</filters>
<filterTables>
<filterTable name="myfilter_tb">
<add filterName="f1" endpointName="calc_sv1"/>
<add filterName="f2" endpointName="calc_sv1"/>
<add filterName="f3" endpointName="calc_sv2"/>
</filterTable>
</filterTables>
</routing>
<behaviors>
<serviceBehaviors>
<behavior name="svbhv">
<serviceMetadata httpGetEnabled="true"/>
<routing filterTableName="myfilter_tb"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
Below is the base address of the routing service:
We can access the routing service through the browser:
Feel free to let me know if the problem persists.
Upvotes: 1