2012-05-31 52 views
2

我試圖託管一個可以從Azure服務總線中繼的REST服務 我看到this blog看起來它會回答我的問題,但不幸的是,我得到了相同的結果。Azure服務總線託管REST服務

這是我嘗試在瀏覽器中訪問服務時收到的異常。

該服務無法激活,因爲它不支持ASP.NET兼容性。 爲此應用程序啓用ASP.NET兼容性。在web.config中關閉ASP.NET兼容模式 或將AspNetCompatibilityRequirements屬性添加到 服務類型,其中RequirementsMode設置爲'允許'或'必需'。

如果我排除在ServiceHostFactory Azure的端點註冊的是(通過basicHttpRelayBinding)連接到Azure的服務總線,我沒有得到這個錯誤,我可以在本地打服務。它與託管RESTful服務(webHttpBinding)和Azure服務總線中繼綁定(basicHttpRelayBinding)有關。

在Global.asax我添加主機

protected void Application_Start(object sender, EventArgs e) 
{ 
    // Add REST service hosting. 
    RouteTable.Routes.Add(new ServiceRoute("myservice/rest", 
     new CustomWebServiceHostFactory(typeof(IMyService)), 
     typeof(MyServiceProvider))); 
} 

我有我的裝飾服務提供商如下服務:

[ServiceBehavior(IncludeExceptionDetailInFaults = true)] 
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 
public class MyServiceProvider : IMyService 
{ 
    ... 
} 

運行在IIS我的服務接口的web.config有以下值:

<configSections> 
    <sectionGroup name="system.serviceModel" type="System.ServiceModel.Configuration.ServiceModelSectionGroup, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <section name="standardEndpoints" type="System.ServiceModel.Configuration.StandardEndpointsSection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/> 
    </sectionGroup>   
</configSections> 

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
    <standardEndpoints> 
     <webHttpEndpoint> 
      <standardEndpoint helpEnabled="true" automaticFormatSelectionEnabled="true"> 
      <security mode="None"/> 
      </standardEndpoint> 
     </webHttpEndpoint> 
    </standardEndpoints> 
... 
</system.serviceModel> 

任何想法?

+0

本帖似乎是同樣的問題](http://forums.silverlight.net/t/21944.aspx),但我不知道是否使用['baseAddressPrefixFilters'](http://msdn.microsoft.com/zh-cn/library/bb924481 .aspx)會解決它。 – SliverNinja

回答