繁体   English   中英

添加新的HTTP和HTTPS绑定后,WCF停止在IIS 7上工作

[英]WCF stopped working on IIS 7 after adding new HTTP and HTTPS bindings

我在C#使用ASP.NET 3.5 我有一个具有WCFweb-application 我已经将它部署在具有Bindings HTTPHTTPS Bindings HTTP服务器上。 一切都很好。

今天,我在同一站点上又添加了两个HTTPHTTPS绑定,但with different host names (我已经注册了该新域,并且已经用我的IP地址指出了这一点)。 突然,该站点的WCF停止工作。

我在IIS两个站点上做到了,它们都在WCF调用中返回异常,但是login和所有其他页面都工作正常。

web.config的ServiceModel部分如下所示:

     <system.serviceModel>
        <bindings>
            <webHttpBinding>
                <binding name="webBindingHTTP">
                    <security mode="TransportCredentialOnly">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
                <binding name="webBindingHTTPS">
                    <security mode="Transport">
                        <transport clientCredentialType="None" />
                    </security>
                </binding>
            </webHttpBinding>
        </bindings>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true">
        </serviceHostingEnvironment>
        <behaviors>
            <endpointBehaviors>
                <behavior name="ihrole.service.remoteBehavior">
                    <webHttp />
                </behavior>
                <behavior name="webHttpEnabled">
                    <webHttp/>
                </behavior>
            </endpointBehaviors>
            <serviceBehaviors>
                <behavior name="ihrole.service.remoteBehavior">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <service behaviorConfiguration="ihrole.service.remoteBehavior" name="ihrole.service.remote">
                <endpoint address="" behaviorConfiguration="ihrole.service.remoteBehavior" bindingConfiguration="webBindingHTTP" binding="webHttpBinding" contract="ihrole.service.Iremote" />
                <endpoint address="" behaviorConfiguration="ihrole.service.remoteBehavior" bindingConfiguration="webBindingHTTPS" binding="webHttpBinding" contract="ihrole.service.Iremote" />
            </service>
        </services>
    </system.serviceModel>

同样,我确实在同一IIS上托管了另一个站点,该站点也具有HTTPHTTPS绑定。 但是我尚未在该站点中添加新的站点,并且WCF调用在同一站点上运行良好。

任何猜测或解决方案? 提前致谢..

在这里,您需要指定WCF服务可以在单个网站的所有绑定上运行。

在Asp.Net 3.5中,当网站具有多个绑定时,应使用<baseAddressPrefixFilters>元素指定“通过过滤器”(为WCF服务添加基地址)。 请参阅下面的示例。 MSDN reference here.

<system.serviceModel>
    <serviceHostingEnvironment>
    ... 
        <baseAddressPrefixFilters>
            <add prefix="http://Testsite2.com:3546"/>
            <add prefix="http://testSite.com:3566"/>
        </baseAddressPrefixFilters>
   ...
    </serviceHostingEnvironment>
</system.serviceModel>

因此,这里http://Testsite2.com:3546http://testSite.com:3566是它们各自方案的唯一基址,将允许它们通过,这意味着WCF服务将可以正常工作这两个地址。 baseAddressPrefixFilter不支持任何通配符。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM