簡體   English   中英

Azure Service Bus托管REST服務

[英]Azure Service Bus Hosting REST Service

我試圖托管一個可以從Azure Service Bus中繼的REST服務,我看到這個博客看起來可以回答我的問題,但是不幸的是,我得到的結果是相同的。

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

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

如果我從連接到Azure服務總線的ServiceHostFactory中排除了Azure端點注冊( 通過basicHttpRelayBinding ),則不會出現此錯誤,並且可以在本地訪問該服務。 它與托管RESTful服務( webHttpBinding )和Azure Service Bus中繼綁定( 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>

有任何想法嗎?

我可以建議您嘗試一下這個博客,該博客顯示出完全相同的問題以及根本原因和解決方案,嘗試應用該建議並讓我們知道:

http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/17/wcf-rest-http-application-connecting-azure-service-bus-using-webhttprelaybinding-causes-aspnetcompatibilityenabled-error.aspx

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM