【发布时间】:2020-12-30 00:57:56
【问题描述】:
我想在 IIS 上创建路由 WCF 服务,它将在 IIS 上调用我的另外两个服务:
- JobWCF1.evgeny.net
- JobWCF2.evgeny.ne
- JobWCFRouter.evgeny.net
如果我在浏览器中调用它们,第一个和第二个服务效果很好:
http://jobwcf1.evgeny.net/JobWCF.svc/Test
http://jobwcf2.evgeny.net/JobWCF.svc/Test
但是当我通过路由服务调用时,它不起作用(HTTP 404)(在浏览器中):
http://jobwcfrouter.evgeny.net/JobWCF.svc/Test
路由器服务的web.config:
<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>
另外,在路由器服务中,我有文件管理器 Router.svc,代码在哪里:
<%@ ServiceHost Language="C#" Debug="true"
Service="System.ServiceModel.Routing.
RoutingService, System.ServiceModel.Routing,
version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
%>
我做错了什么?
【问题讨论】:
-
404可能与 IIS 无法解析您尝试调用的RoutingService上的Test操作有关。从您共享的配置中,我不确定您是如何设置的? -
您好,问题解决了吗?如果您认为我的回复对您有帮助,您可以将其标记为答案。