简体   繁体   English

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

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

I am using ASP.NET 3.5 with C# . 我在C#使用ASP.NET 3.5 I have a web-application that have a WCF . 我有一个具有WCFweb-application I had deployed it on Server with Bindings HTTP and HTTPS . 我已经将它部署在具有Bindings HTTPHTTPS Bindings HTTP服务器上。 Everything was working well. 一切都很好。

Today I added two more bindings of HTTP and HTTPS on the same site but with different host names . 今天,我在同一站点上又添加了两个HTTPHTTPS绑定,但with different host names (I have that new domain registered and I already have pointed that with my IP address). (我已经注册了该新域,并且已经用我的IP地址指出了这一点)。 And suddenly, the WCF for that same site stopped working. 突然,该站点的WCF停止工作。

I did it for two sites in IIS and both of them are returning exception on WCF call, however the login and all other pages are working fine. 我在IIS两个站点上做到了,它们都在WCF调用中返回异常,但是login和所有其他页面都工作正常。

The ServiceModel part of web.config is as below : 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>

Again, I do have another site hosted on the same IIS that is also having HTTP and HTTPS bindings. 同样,我确实在同一IIS上托管了另一个站点,该站点也具有HTTPHTTPS绑定。 But I haven't added the new ones in this site and the WCF call is working fine on the same. 但是我尚未在该站点中添加新的站点,并且WCF调用在同一站点上运行良好。

Any guess or solution? 任何猜测或解决方案? Thanks in advance.. 提前致谢..

Here you need to specify that your WCF service can be run on all Bindings for a single website. 在这里,您需要指定WCF服务可以在单个网站的所有绑定上运行。

In Asp.Net 3.5, when a website has multiple bindings, you should specify Pass through filters ( adding a base address for the WCF service ) using the <baseAddressPrefixFilters> element. 在Asp.Net 3.5中,当网站具有多个绑定时,应使用<baseAddressPrefixFilters>元素指定“通过过滤器”(为WCF服务添加基地址)。 See Sample below. 请参阅下面的示例。 MSDN reference here.

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

So, here http://Testsite2.com:3546 and http://testSite.com:3566 are the only base addresses, for their respective schemes, which will be allowed to be passed through, which means simply that WCF service will work for these two addresses. 因此,这里http://Testsite2.com:3546http://testSite.com:3566是它们各自方案的唯一基址,将允许它们通过,这意味着WCF服务将可以正常工作这两个地址。 The baseAddressPrefixFilter does not support any wildcards . baseAddressPrefixFilter不支持任何通配符。

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

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