Azure 服务总线托管 REST 服务
本文关键字:服务 REST 总线 Azure | 更新日期: 2023-09-27 18:35:50
我正在尝试托管可从 Azure 服务总线中继的 REST 服务我看到这个博客,看起来它会回答我的问题,但不幸的是,我得到了相同的结果。
这是我尝试在浏览器中点击服务时收到的异常。
无法激活该服务,因为它不支持 ASP.NET 兼容性。 为此应用程序启用了 ASP.NET 兼容性。关闭 ASP.NET 兼容性 模式或将 AspNetCompatibility Requirements 属性添加到 "要求模式"设置为"允许"或"必需"的服务类型。
如果我从连接到 Azure 服务总线的ServiceHostFactory
中排除 Azure 终结点注册(通过 basicHttpRelayBinding
),则不会收到此错误,我可以在本地访问服务。它与托管 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>
有什么想法吗?
我可以建议您尝试我的博客,该博客显示了完全相同的问题以及根本原因和解决方案,请尝试应用该建议并告诉我们:
http://blogs.msdn.com/b/avkashchauhan/archive/2011/11/17/wcf-rest-http-application-connecting-azure-service-bus-using-webhttprelaybinding-causes-aspnetcompatibilityenabled-error.aspx