使用WCF REST模板的Azure Service Bus webHttpRelayBinding导致不必要的aspNetCompatibilityEnabled错误

时间:2011-09-07 09:24:57

标签: azure wcf-rest webhttpbinding servicebus

我正在使用Azure Service Bus webHttpRelayBinding使用WCF REST模板,但即使我的服务类正确装饰,它也会导致不必要的aspNetCompatibilityEnabled错误:

 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
    [ServiceContract( Namespace = "http://samples.microsoft.com/ServiceModel/Relay/")]    
    public class InsightDataService //: Insight.WebAPI.WCFRestImplementation.IInsightDataService
    {...

我的网站.Config: -

 <system.serviceModel>
    <services>
      <service name="compname.WebAPI.WCFRestImplementation.InsightDataService" behaviorConfiguration="InsightDataServiceBehavior">
        <endpoint address="https://namespacename.servicebus.windows.net/InsightDataService"
                  binding="webHttpRelayBinding"
                  contract="compname.WebAPI.WCFRestImplementation.InsightDataService"
                  behaviorConfiguration="sharedSecret"                  
                   name="default"
                  >
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://namespacename.servicebus.windows.net/InsightDataService"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <webHttpRelayBinding>
        <binding name="webHttpRelayBinding"
                  maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647"
                  receiveTimeout="00:30:00"
                  sendTimeout="00:30:00"
                  openTimeout="00:30:00"
                  closeTimeout="00:30:00">
          <security mode="None"></security>
        </binding>
      </webHttpRelayBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="InsightDataServiceBehavior">
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceMetadata httpGetEnabled="True" />

          <serviceThrottling
              maxConcurrentCalls="20"
              maxConcurrentInstances="2147483647"
              maxConcurrentSessions="20"/>
        </behavior>
      </serviceBehaviors>

      <endpointBehaviors>
        <behavior name="sharedSecret">

          <transportClientEndpointBehavior credentialType="SharedSecret">
            <clientCredentials>
              <sharedSecret issuerName="owner"
               issuerSecret="****************securitykey**********" />                            
            </clientCredentials>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <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="default" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
      </webHttpEndpoint>
    </standardEndpoints>
  </system.serviceModel>

例外是: -

[InvalidOperationException: The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'.]
   System.ServiceModel.Activation.HostedAspNetEnvironment.ValidateCompatibilityRequirements(AspNetCompatibilityRequirementsMode compatibilityMode) +119682
   System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) +31
   System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +190
   System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +109
   System.ServiceModel.ServiceHostBase.InitializeRuntime() +60
   System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +50
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
   Microsoft.ServiceBus.RelayedSocketListener.Open(TimeSpan timeout) +56
   Microsoft.ServiceBus.Channels.BufferedConnectionListener.Open(TimeSpan timeout) +55
   Microsoft.ServiceBus.Channels.ConnectionAcceptor.Open(TimeSpan timeout) +55
   Microsoft.ServiceBus.Channels.ConnectionDemuxer.StartDemuxing(TimeSpan timeout, OnViaDelegate viaDelegate) +74
   Microsoft.ServiceBus.Channels.ConnectionDemuxer.Open(TimeSpan timeout) +46
   Microsoft.ServiceBus.SocketConnectionTransportManager.OnOpen(TimeSpan timeout) +639
   Microsoft.ServiceBus.Channels.TransportManager.Open(TimeSpan timeout, TransportChannelListener channelListener) +687
   Microsoft.ServiceBus.Channels.TransportManagerContainer.Open(TimeSpan timeout, SelectTransportManagersCallback selectTransportManagerCallback) +286
   Microsoft.ServiceBus.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) +106
   Microsoft.ServiceBus.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout) +92
   Microsoft.ServiceBus.SocketConnectionChannelListener`2.OnOpen(TimeSpan timeout) +106
   Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout) +658
   Microsoft.ServiceBus.Channels.LayeredChannelListener`1.OnOpen(TimeSpan timeout) +89
   Microsoft.ServiceBus.Channels.CommunicationObject.Open(TimeSpan timeout) +658
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +72

[InvalidOperationException: The ChannelDispatcher at 'sb://namespacename.servicebus.windows.net/InsightDataService' with contract(s) '"InsightDataService"' is unable to open its IChannelListener.]
   System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +118
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
   System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +111
   System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +318
   System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +206
   System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651

[ServiceActivationException: The service '/InsightDataService' cannot be activated due to an exception during compilation.  The exception message is: The ChannelDispatcher at 'sb://namespacename.servicebus.windows.net/InsightDataService' with contract(s) '"InsightDataService"' is unable to open its IChannelListener..]
   System.Runtime.AsyncResult.End(IAsyncResult result) +688590
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190
   System.ServiceModel.Activation.AspNetRouteServiceHttpHandler.EndProcessRequest(IAsyncResult result) +6
   System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +96

0 个答案:

没有答案