Beispiel #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);
        }
        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);
        }