WCF Rest服务在IIS 8中无法通过HTTP工作
我的团队有一个用.NET4.0编写的小型WCF Rest服务。以前,它已使用以下绑定配置部署在运行IIS 7的Server 2008计算机上:WCF Rest服务在IIS 8中无法通过HTTP工作,wcf,wcf-binding,iis-8,Wcf,Wcf Binding,Iis 8,我的团队有一个用.NET4.0编写的小型WCF Rest服务。以前,它已使用以下绑定配置部署在运行IIS 7的Server 2008计算机上: <bindings> <webHttpBinding> <binding name="httpsBinding"> <security mode="Transport"/> </binding> </webHttpBinding> </bin
<bindings>
<webHttpBinding>
<binding name="httpsBinding">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
正如人们所期望的,只要web服务器配置了HTTP或HTTPS的绑定,该服务就可以很好地使用HTTP或HTTPS
但是,当我们在运行IIS 8的Server 2012 box上安装该服务时,该服务将通过HTTPS正常工作,但通过HTTP的请求失败,状态为404
我们已经研究了Server2008和Server2012机器的IIS配置,但没有任何明显的罪魁祸首。所有设置似乎都相同
是否有任何额外的配置需要在IIS或web配置中完成?关于使用HTTP而不是HTTPS的服务,SO和MSDN上有很多问题,但我没有看到相反的问题
编辑:
根据WCF跟踪日志,2008计算机在HTTP和HTTPS上同时打开端点侦听器,而2012计算机仅为HTTPS打开端点侦听器
为了确保我没有遗漏服务本身的任何内容,我在两台机器上安装了相同的MSI,甚至在2012框上用2008框中的web.config重写了web.config(尽管它们本来应该是相同的)。行为没有改变
编辑2:
下面是web.config的全部内容:
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="None"/>
<compilation targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service name="service1">
<endpoint behaviorConfiguration="webHttp" binding="webHttpBinding" bindingConfiguration="httpsBinding" contract="service1"/>
</service>
<service name="service2">
<endpoint behaviorConfiguration="webHttp" binding="webHttpBinding" bindingConfiguration="httpsBinding" contract="service2"/>
</service>
<service name="service3">
<endpoint behaviorConfiguration="webHttp" binding="webHttpBinding" bindingConfiguration="httpsBinding" contract="service3"/>
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="httpsBinding">
<security mode="Transport"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="webHttp">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
为每个服务添加一个HTTP端点,如下所示:
<endpoint behaviorConfiguration="webHttp" binding="webHttpBinding" bindingConfiguration="httpBinding" contract="service3"/>
和仅用于HTTP的关联绑定:
<binding name="httpBinding">
<security mode="None"/>
</binding>
您只向我们显示您在客户端收到的404,而您应该从服务器端对此进行诊断。您的IIS日志对错误的确切原因有何说明?WCF跟踪告诉您什么,消息是否在WCF管道中结束?非WCF请求是否在同一应用程序上工作?HTTP状态404代码通常意味着您使用的URL无法映射到服务操作。如果出现身份验证错误,您将获得403。请尝试确保HTTP请求通过IIS进入WCF管道。请显示服务配置的其余部分。