我正在尝试启用一个可以使用两个绑定的应用程序。 由于我要将它分发给客户端,因此有些IIS会打开HTTP和HTTPS,有些可能只有其中一个。 我无法根据IIS的配置完成提供HTTP和HTTPS访问的任务。 这是我的web.config:
<system.serviceModel>
<services>
<service behaviorConfiguration="RoutingBehavior" name="System.ServiceModel.Routing.RoutingService">
<endpoint address="" behaviorConfiguration="WebBehaviorHTTPS" binding="basicHttpBinding" bindingConfiguration="BasicSSL" name="RouterEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter" >
</endpoint>
<endpoint address="http://" behaviorConfiguration="WebBehavior" binding="basicHttpBinding" bindingConfiguration="Basic" name="RouterEndpoint" contract="System.ServiceModel.Routing.IRequestReplyRouter" >
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="RoutingBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehaviorHTTPS">
<webHttp/>
</behavior>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="Basic" receiveTimeout="02:30:00" sendTimeout="02:30:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None">
<transport clientCredentialType="None" />
</security>
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
</binding>
<binding name="BasicSSL" receiveTimeout="02:30:00" sendTimeout="02:30:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="False" multipleSiteBindingsEnabled="True">
<serviceActivations>
<add relativeAddress="EZRouterService.svc" service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" factory="Equivio.Zoom.Web.EZRouterServiceFactory"/>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
编辑:访问应用程序时,使用第一个绑定(首先是上面列表中的第一个绑定)。当我切换到HTTP环境时,我无法访问。
调试时我得到以下异常:
其他信息:找不到与绑定BasicHttpBinding的端点的scheme http匹配的基址。注册的基地址方案是[https]。
答案 0 :(得分:0)
我建议为两个服务端点提供唯一的NAME值,并设置它们使用相同的ADDRESS,因为它们已经有不同的bindingConfiguration和behaviorConfiguration。
<services>
<service behaviorConfiguration="RoutingBehavior" name="System.ServiceModel.Routing.RoutingService">
<endpoint address="" behaviorConfiguration="WebBehaviorHTTPS" binding="basicHttpBinding" bindingConfiguration="BasicSSL" name="RouterEndpointSSL" contract="System.ServiceModel.Routing.IRequestReplyRouter" >
</endpoint>
<endpoint address="" behaviorConfiguration="WebBehavior" binding="basicHttpBinding" bindingConfiguration="Basic" name="RouterEndpointBasic" contract="System.ServiceModel.Routing.IRequestReplyRouter" >
</endpoint>
</service>
</services>
我相信你当前的relativeAddress =&#34; EZRouterService.svc&#34;和端点地址=&#34; http://&#34; ,因为该值不是一个完整的地址,所以需要用于http的http是http:// {baseadress} /EZRouterService.svc/http://可能会造成一些混乱。