2011-02-15 46 views
0

又一次尝试使用部署到IIS 7.5的basicHttpBinding获取WCF Rest(no svc文件)服务失败。我相信我的网站与IIS一起正确配置。我确定问题在于我的配置。我收到的回应是500错误。我有一个MVC 3网络在这个盒子上运行良好。WCF Rest with basicHttpBinding on IIS 7.5 500 error

WCF Rest服务正在使用basicHttpBinding和Transportcredentialonly的安全模式。这是我的配置;

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
    <handlers> 
     <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </handlers> 
</system.webServer> 
<system.serviceModel> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="AuthBinding"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Basic"></transport> 
      </security> 
     </binding> 
     </basicHttpBinding> 
    </bindings> 
    <services> 
     <service name="NamedService"> 
     <endpoint contract="Namespace.IService" binding="basicHttpBinding" bindingConfiguration="AuthBinding"></endpoint> 
     </service> 
    </services> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" /> 
     </webHttpEndpoint> 
    </standardEndpoints> 
</system.serviceModel> 

当前Web和IIS配置基于其他职位;

  • 我对网络产生的V4.0应用程序池
  • 我有一个网站创建了上面的应用程序池
  • 我已经从32位和64位.NET V4 ISAPI筛选器启用
  • 相关我再次V4注册-i的Aspnet_regiis.exe
  • 我有HTTP重定向安装
  • 我有基本身份验证启用

任何帮助将不胜感激。我一直在这一天。顺便说一句...我没有看到任何事件消息。我知道DNS配置正确,因为我可以剥离WCF的东西,并把一个临时的HTML页面在网络上,它的工作原理。

---------------- UPDATE --------------------- 即使使用后仍然有问题剥离配置。我遗漏的几件事是这是一个x64操作系统,我使用城堡作为IoC。我确实运行了Frameword64/aspnet_regiis.exe。

<?xml version="1.0"?> 
<configuration> 
    <configSections> 
    <section name="castle" type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler, Castle.Windsor"/> 
    </configSections> 
    <connectionStrings> 
    <add name="Main.ConnectionString" connectionString="data source=blah;initial catalog=newdatabase;User ID=web;Password=testing;persist security info=False;packet size=4096;" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <system.web> 
    <compilation targetFramework="4.0" /> 
    <httpModules> 
     <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" /> 
    </httpModules> 
    </system.web> 
    <castle> 
    <properties> 
     <myConnStr>data source=blah;initial catalog=newdatabase;User ID=web;Password=testing;persist security info=False;packet size=4096;" providerName="System.Data.SqlClient</myConnStr> 
    </properties> 
    <components> 
     <component id="RestService" service="Namespace.Rest.IRestService, Namespace.Rest" type="Namespace.Rest.RestService, Namespace.Rest" lifestyle="PerWebRequest"/> 
     <component id="Repository" service="Namespace.Domain.Interfaces.IRepository, Namespace.Domain" type="Namespace.Domain.Repository, Thumbfound.Domain" lifestyle="PerWebRequest"> 
     <parameters> 
      <connectionString>#{myConnStr}</connectionString> 
     </parameters> 
     </component> 
    </components> 
    </castle> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    </modules> 
    </system.webServer> 
    <system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/> 
    <standardEndpoints> 
     <webHttpEndpoint> 
     <!-- 
      Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
      via the attributes on the <standardEndpoint> element below 
     --> 
     <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/> 
     </webHttpEndpoint> 
    </standardEndpoints> 
    </system.serviceModel> 
</configuration> 

回答

4

另一个失败尝试使用 basicHttpBinding的部署到IIS 7.5获得 WCF 休息(无SVC文件)服务。

有你的问题就在那里 - WCF REST 必须使用webHttpBinding - basicHttpBinding(这是一个SOAP绑定)。

+0

yikes ...一天浪费在绑定上。谢谢! – vince 2011-02-15 06:01:39

1

原来这是Castle Windsor的配置问题。

的分辨率问题已经内<system.web>去除<httpmodules>部分,并把我的PerRequestLifestyleModule配置在<system.webServer><modules>部分。我猜IIS 7不喜欢集成模式下的httpmodules。