Exemple #1
0
        private void HandleRequest()
        {
            string aspNetRouteServiceVirtualPath;

            this.OriginalRequestUri = this.GetUrl();
            if (!string.IsNullOrEmpty(this.AspNetRouteServiceVirtualPath))
            {
                aspNetRouteServiceVirtualPath = this.AspNetRouteServiceVirtualPath;
            }
            else if (!string.IsNullOrEmpty(this.configurationBasedServiceVirtualPath))
            {
                aspNetRouteServiceVirtualPath = this.configurationBasedServiceVirtualPath;
            }
            else
            {
                aspNetRouteServiceVirtualPath = this.GetAppRelativeCurrentExecutionFilePath();
            }
            if (this.ensureWFService)
            {
                bool flag = false;
                try
                {
                    if (!ServiceHostingEnvironment.EnsureWorkflowService(aspNetRouteServiceVirtualPath))
                    {
                        this.CompleteOperation(null);
                        flag = true;
                        return;
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        this.CompleteRequest();
                    }
                }
            }
            if (ServiceHostingEnvironment.IsSimpleApplicationHost)
            {
                HostedTransportConfigurationManager.EnsureInitializedForSimpleApplicationHost(this);
            }
            HttpHostedTransportConfiguration configuration        = HostedTransportConfigurationManager.GetConfiguration(this.OriginalRequestUri.Scheme) as HttpHostedTransportConfiguration;
            HostedHttpTransportManager       httpTransportManager = null;

            if (configuration != null)
            {
                httpTransportManager = configuration.GetHttpTransportManager(this.OriginalRequestUri);
            }
            if (httpTransportManager == null)
            {
                InvalidOperationException  innerException      = new InvalidOperationException(System.ServiceModel.Activation.SR.Hosting_TransportBindingNotFound(this.OriginalRequestUri.ToString()));
                ServiceActivationException activationException = new ServiceActivationException(innerException.Message, innerException);
                this.LogServiceActivationException(activationException);
                throw System.ServiceModel.Activation.FxTrace.Exception.AsError(activationException);
            }
            this.RequestUri = new Uri(httpTransportManager.ListenUri, this.OriginalRequestUri.PathAndQuery);
            ServiceHostingEnvironment.EnsureServiceAvailableFast(aspNetRouteServiceVirtualPath);
            httpTransportManager.HttpContextReceived(this);
        }
Exemple #2
0
 internal static void EnsureInitializedForSimpleApplicationHost(HostedHttpRequestAsyncResult result)
 {
     if (singleton == null)
     {
         lock (syncRoot)
         {
             if (singleton == null)
             {
                 singleton = new HostedTransportConfigurationManager(new MetabaseSettingsCassini(result));
             }
         }
     }
 }
        public override BaseUriWithWildcard GetBaseUri(string transportScheme, Uri listenUri)
        {
            BaseUriWithWildcard wildcard = null;
            HostedTransportConfigurationBase configuration = HostedTransportConfigurationManager.GetConfiguration(transportScheme) as HostedTransportConfigurationBase;

            if (configuration != null)
            {
                wildcard = configuration.FindBaseAddress(listenUri);
                if (wildcard == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activation.SR.Hosting_TransportBindingNotFound(listenUri.ToString())));
                }
            }
            return(wildcard);
        }
Exemple #4
0
        public override BaseUriWithWildcard GetBaseUri(string transportScheme, Uri listenUri)
        {
            BaseUriWithWildcard baseAddress = null;
            HostedTransportConfigurationBase hostedConfiguration =
                HostedTransportConfigurationManager.GetConfiguration(transportScheme) as HostedTransportConfigurationBase;

            if (hostedConfiguration != null)
            {
                baseAddress = hostedConfiguration.FindBaseAddress(listenUri);
                if (baseAddress == null)
                {
                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Hosting_TransportBindingNotFound(listenUri.ToString())));
                }
            }
            return(baseAddress);
        }
        internal static void EnsureInitializedForSimpleApplicationHost(HostedHttpRequestAsyncResult result)
        {
            if (singleton != null)
            {
                return;
            }

            lock (syncRoot)
            {
                if (singleton != null)
                    return;

                singleton = new HostedTransportConfigurationManager(new MetabaseSettingsCassini(result));
            }
        }
        void HandleRequest()
        {
            this.OriginalRequestUri = GetUrl();
            string relativeVirtualPath;

            if (!string.IsNullOrEmpty(this.AspNetRouteServiceVirtualPath))
            {
                relativeVirtualPath = this.AspNetRouteServiceVirtualPath;
            }
            else if (!string.IsNullOrEmpty(this.configurationBasedServiceVirtualPath))
            {
                relativeVirtualPath = this.configurationBasedServiceVirtualPath;
            }
            else
            {
                relativeVirtualPath = GetAppRelativeCurrentExecutionFilePath();
            }

            if (ensureWFService)
            {
                bool bypass = false;
                try
                {
                    if (!ServiceHostingEnvironment.EnsureWorkflowService(relativeVirtualPath))
                    {
                        CompleteOperation(null);
                        bypass = true;
                        return;
                    }
                }
                finally
                {
                    if (!bypass)
                    {
                        CompleteRequest();
                    }
                }
            }

            // Support for Cassini.
            if (ServiceHostingEnvironment.IsSimpleApplicationHost)
            {
                HostedTransportConfigurationManager.EnsureInitializedForSimpleApplicationHost(this);
            }

            HttpHostedTransportConfiguration transportConfiguration = HostedTransportConfigurationManager.GetConfiguration(this.OriginalRequestUri.Scheme)
                                                                      as HttpHostedTransportConfiguration;
            HostedHttpTransportManager transportManager = null;

            // There must be a transport binding that matches the request.
            if (transportConfiguration != null)
            {
                transportManager = transportConfiguration.GetHttpTransportManager(this.OriginalRequestUri);
            }

            if (transportManager == null)
            {
                InvalidOperationException invalidOpException = new InvalidOperationException(SR.Hosting_TransportBindingNotFound(OriginalRequestUri.ToString()));

                ServiceActivationException activationException = new ServiceActivationException(invalidOpException.Message, invalidOpException);

                LogServiceActivationException(activationException);

                throw FxTrace.Exception.AsError(activationException);
            }

            this.RequestUri = new Uri(transportManager.ListenUri, this.OriginalRequestUri.PathAndQuery);
            Fx.Assert(
                object.ReferenceEquals(this.RequestUri.Scheme, Uri.UriSchemeHttp) || object.ReferenceEquals(this.RequestUri.Scheme, Uri.UriSchemeHttps),
                "Scheme must be Http or Https.");

            ServiceHostingEnvironment.EnsureServiceAvailableFast(relativeVirtualPath, this.eventTraceActivity);

            transportManager.HttpContextReceived(this);
        }