Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
 private void LogServiceActivationException(ServiceActivationException activationException)
 {
     if (System.ServiceModel.Diagnostics.Application.TD.ServiceExceptionIsEnabled())
     {
         System.ServiceModel.Diagnostics.Application.TD.ServiceException(activationException.ToString(), typeof(ServiceActivationException).FullName);
     }
     DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, EventLogCategory.WebHost, (System.ServiceModel.Diagnostics.EventLogEventId)(-1073610749), true, new string[] { System.ServiceModel.Activation.Diagnostics.TraceUtility.CreateSourceString(this), activationException.ToString() });
 }
        void LogServiceActivationException(ServiceActivationException activationException)
        {
            if (TD2.ServiceExceptionIsEnabled())
            {
                TD2.ServiceException(this.eventTraceActivity, activationException.ToString(), typeof(ServiceActivationException).FullName);
            }

            if (TD.ServiceActivationExceptionIsEnabled())
            {
                TD.ServiceActivationException(activationException != null ? activationException.ToString() : string.Empty, activationException);
            }
            DiagnosticUtility.UnsafeEventLog.UnsafeLogEvent(TraceEventType.Error, (ushort)System.Runtime.Diagnostics.EventLogCategory.WebHost,
                                                            (uint)System.Runtime.Diagnostics.EventLogEventId.WebHostFailedToProcessRequest, true,
                                                            TraceUtility.CreateSourceString(this), activationException.ToString());
        }
        private void ContinueReading()
        {
            bool flag = false;

            try
            {
                try
                {
                    while (true)
                    {
                        if (this.size == 0)
                        {
                            if (Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback == null)
                            {
                                Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback = new WaitCallback(Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.ReadCallback);
                            }
                            if (base.Connection.BeginRead(0, (int)this.connectionBuffer.Length, this.GetRemainingTimeout(), Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader.readCallback, this) == AsyncReadResult.Queued)
                            {
                                break;
                            }
                            this.GetReadResult();
                        }
                        int num = this.decoder.Decode(this.connectionBuffer, this.offset, this.size);
                        if (num > 0)
                        {
                            Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleConnectionReader = this;
                            serverSessionPreambleConnectionReader.offset = serverSessionPreambleConnectionReader.offset + num;
                            Microsoft.ServiceBus.Channels.ServerSessionPreambleConnectionReader serverSessionPreambleConnectionReader1 = this;
                            serverSessionPreambleConnectionReader1.size = serverSessionPreambleConnectionReader1.size - num;
                        }
                        if (this.decoder.CurrentState == Microsoft.ServiceBus.Channels.ServerSessionDecoder.State.PreUpgradeStart)
                        {
                            this.via = this.decoder.Via;
                            if (base.Connection.Validate(this.via))
                            {
                                if (this.viaDelegate != null)
                                {
                                    try
                                    {
                                        this.viaDelegate(this.via);
                                    }
                                    catch (ServiceActivationException serviceActivationException1)
                                    {
                                        ServiceActivationException serviceActivationException = serviceActivationException1;
                                        if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                                        {
                                            Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(serviceActivationException, TraceEventType.Information);
                                        }
                                        this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/ServiceActivationFailed");
                                        break;
                                    }
                                }
                                this.settings = this.transportSettingsCallback(this.via);
                                if (this.settings != null)
                                {
                                    this.callback(this);
                                    break;
                                }
                                else
                                {
                                    string   endpointNotFound = Resources.EndpointNotFound;
                                    object[] via = new object[] { this.decoder.Via };
                                    EndpointNotFoundException endpointNotFoundException = new EndpointNotFoundException(Microsoft.ServiceBus.SR.GetString(endpointNotFound, via));
                                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                                    {
                                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(endpointNotFoundException, TraceEventType.Information);
                                    }
                                    this.SendFault("http://schemas.microsoft.com/ws/2006/05/framing/faults/EndpointNotFound");
                                    return;
                                }
                            }
                            else
                            {
                                return;
                            }
                        }
                    }
                    flag = true;
                }
                catch (CommunicationException communicationException1)
                {
                    CommunicationException communicationException = communicationException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(communicationException, TraceEventType.Information);
                    }
                }
                catch (TimeoutException timeoutException1)
                {
                    TimeoutException timeoutException = timeoutException1;
                    if (Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ShouldTraceInformation)
                    {
                        Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.TraceHandledException(timeoutException, TraceEventType.Information);
                    }
                }
                catch (Exception exception1)
                {
                    Exception exception = exception1;
                    if (Fx.IsFatal(exception))
                    {
                        throw;
                    }
                    if (!ExceptionHandler.HandleTransportExceptionHelper(exception))
                    {
                        throw;
                    }
                }
            }
            finally
            {
                if (!flag)
                {
                    base.Abort();
                }
            }
        }
        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);
        }