Пример #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);
        }
Пример #2
0
        void EnsureInitialized()
        {
            if (!initialized)
            {
                lock (ThisLock)
                {
                    if (!initialized)
                    {
                        // Register protocols.
                        foreach (string protocol in metabaseSettings.GetProtocols())
                        {
                            // special case HTTP, it's a legacy protocol
                            if (string.CompareOrdinal(protocol, Uri.UriSchemeHttp) == 0 ||
                                string.CompareOrdinal(protocol, Uri.UriSchemeHttps) == 0)
                            {
                                HttpHostedTransportConfiguration httpConfiguration = null;
                                if (string.CompareOrdinal(protocol, Uri.UriSchemeHttp) == 0)
                                {
                                    httpConfiguration = new HttpHostedTransportConfiguration();
                                }
                                else
                                {
                                    httpConfiguration = new HttpsHostedTransportConfiguration();
                                }

                                configurations.Add(protocol, httpConfiguration);
                            }
                            else
                            {
                                if (!Iis7Helper.IsIis7)
                                {
                                    throw Fx.AssertAndThrowFatal("HostedTransportConfigurationManager.EnsureInitialized() protocols other than http and https can only be configured in IIS7");
                                }
                                if (AspNetPartialTrustHelpers.NeedPartialTrustInvoke)
                                {
                                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.PartialTrustNonHttpActivation(protocol, HostingEnvironmentWrapper.ApplicationVirtualPath)));
                                }
                                AddHostedTransportConfigurationIis7(protocol);
                            }
                        }

                        initialized = true;
                    }
                }
            }
        }
Пример #3
0
 private void EnsureInitialized()
 {
     if (!this.initialized)
     {
         lock (this.ThisLock)
         {
             if (!this.initialized)
             {
                 foreach (string str in this.metabaseSettings.GetProtocols())
                 {
                     if ((string.CompareOrdinal(str, Uri.UriSchemeHttp) == 0) || (string.CompareOrdinal(str, Uri.UriSchemeHttps) == 0))
                     {
                         HttpHostedTransportConfiguration configuration = null;
                         if (string.CompareOrdinal(str, Uri.UriSchemeHttp) == 0)
                         {
                             configuration = new HttpHostedTransportConfiguration();
                         }
                         else
                         {
                             configuration = new HttpsHostedTransportConfiguration();
                         }
                         this.configurations.Add(str, configuration);
                     }
                     else
                     {
                         if (!Iis7Helper.IsIis7)
                         {
                             throw Fx.AssertAndThrowFatal("HostedTransportConfigurationManager.EnsureInitialized() protocols other than http and https can only be configured in IIS7");
                         }
                         if (AspNetPartialTrustHelpers.NeedPartialTrustInvoke)
                         {
                             throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activation.SR.PartialTrustNonHttpActivation(str, HostingEnvironmentWrapper.ApplicationVirtualPath)));
                         }
                         this.AddHostedTransportConfigurationIis7(str);
                     }
                 }
                 this.initialized = true;
             }
         }
     }
 }
        void EnsureInitialized()
        {
            if (!initialized)
            {
                lock (ThisLock)
                {
                    if (!initialized)
                    {
                        // Register protocols.
                        foreach (string protocol in metabaseSettings.GetProtocols())
                        {
                            // special case HTTP, it's a legacy protocol
                            if (string.CompareOrdinal(protocol, Uri.UriSchemeHttp) == 0 ||
                                string.CompareOrdinal(protocol, Uri.UriSchemeHttps) == 0)
                            {
                                HttpHostedTransportConfiguration httpConfiguration = null;
                                if (string.CompareOrdinal(protocol, Uri.UriSchemeHttp) == 0)
                                {
                                    httpConfiguration = new HttpHostedTransportConfiguration();
                                }
                                else
                                {
                                    httpConfiguration = new HttpsHostedTransportConfiguration();
                                }

                                configurations.Add(protocol, httpConfiguration);
                            }
                            else
                            {
                                if (!Iis7Helper.IsIis7)
                                {
                                    throw Fx.AssertAndThrowFatal("HostedTransportConfigurationManager.EnsureInitialized() protocols other than http and https can only be configured in IIS7");
                                }
                                if (AspNetPartialTrustHelpers.NeedPartialTrustInvoke)
                                {
                                    throw FxTrace.Exception.AsError(new InvalidOperationException(SR.PartialTrustNonHttpActivation(protocol, HostingEnvironmentWrapper.ApplicationVirtualPath)));
                                }
                                AddHostedTransportConfigurationIis7(protocol);
                            }
                        }

                        initialized = true;
                    }
                }
            }
        }
        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);
        }
 private void EnsureInitialized()
 {
     if (!this.initialized)
     {
         lock (this.ThisLock)
         {
             if (!this.initialized)
             {
                 foreach (string str in this.metabaseSettings.GetProtocols())
                 {
                     if ((string.CompareOrdinal(str, Uri.UriSchemeHttp) == 0) || (string.CompareOrdinal(str, Uri.UriSchemeHttps) == 0))
                     {
                         HttpHostedTransportConfiguration configuration = null;
                         if (string.CompareOrdinal(str, Uri.UriSchemeHttp) == 0)
                         {
                             configuration = new HttpHostedTransportConfiguration();
                         }
                         else
                         {
                             configuration = new HttpsHostedTransportConfiguration();
                         }
                         this.configurations.Add(str, configuration);
                     }
                     else
                     {
                         if (!Iis7Helper.IsIis7)
                         {
                             throw Fx.AssertAndThrowFatal("HostedTransportConfigurationManager.EnsureInitialized() protocols other than http and https can only be configured in IIS7");
                         }
                         if (AspNetPartialTrustHelpers.NeedPartialTrustInvoke)
                         {
                             throw FxTrace.Exception.AsError(new InvalidOperationException(System.ServiceModel.Activation.SR.PartialTrustNonHttpActivation(str, HostingEnvironmentWrapper.ApplicationVirtualPath)));
                         }
                         this.AddHostedTransportConfigurationIis7(str);
                     }
                 }
                 this.initialized = true;
             }
         }
     }
 }