public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
        {
#if TARGET_J2EE
            string fp = url;
#else
            string fp = filePath != null?filePath.Replace(HttpRuntime.AppDomainAppPath, "/").Replace(Path.DirectorySeparatorChar, '/') : null;
#endif

            Type type;
#if NET_2_0 && !TARGET_JVM
            type = BuildManager.GetCompiledType(url);
#else
            type = WebServiceParser.GetCompiledType(fp, context);
#endif

            WSProtocol protocol = GuessProtocol(context, verb);
#if NET_2_0
            context.Items ["WebServiceSoapVersion"] =
                protocol == WSProtocol.HttpSoap12 ?
                SoapProtocolVersion.Soap12 :
                SoapProtocolVersion.Default;
#endif
            bool         supported = false;
            IHttpHandler handler   = null;

            supported = WSConfig.IsSupported(protocol);
            if (!supported)
            {
                switch (protocol)
                {
#if NET_2_0
                default:
                    if (((protocol & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) &&
                        (WSConfig.Current.EnabledProtocols & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown)
                    {
                        throw new InvalidOperationException("Possible SOAP version mismatch.");
                    }
                    break;
#endif
                case WSProtocol.HttpPost:
                    if (WSConfig.IsSupported(WSProtocol.HttpPostLocalhost))
                    {
#if NET_2_0
                        supported = context.Request.IsLocal;
#else
                        string localAddr = context.Request.ServerVariables ["LOCAL_ADDR"];

                        supported = localAddr != null &&
                                    (localAddr == context.Request.ServerVariables ["REMOTE_ADDR"] ||
                                     IPAddress.IsLoopback(IPAddress.Parse(localAddr)));
#endif
                    }
                    break;
                }
            }
            if (!supported)
            {
                throw new InvalidOperationException("Unsupported request format.");
            }

            switch (protocol)
            {
            case WSProtocol.HttpSoap12:
            case WSProtocol.HttpSoap:
                handler = GetTypeHandler(context, new HttpSoapWebServiceHandler(type));
                break;

            case WSProtocol.HttpPost:
            case WSProtocol.HttpGet:
                handler = GetTypeHandler(context, new HttpSimpleWebServiceHandler(type, protocol.ToString()));
                break;

            case WSProtocol.Documentation:
                SoapDocumentationHandler soapHandler;
                soapHandler = new SoapDocumentationHandler(type, context);
                if (soapHandler.PageHandler is IRequiresSessionState)
                {
                    if (soapHandler.PageHandler is IReadOnlySessionState)
                    {
                        handler = new ReadOnlySessionWrapperHandler(soapHandler);
                    }
                    else
                    {
                        handler = new SessionWrapperHandler(soapHandler);
                    }
                }
                else
                {
                    handler = soapHandler;
                }
                break;
            }

            return(handler);
        }
        public IHttpHandler GetHandler(HttpContext context, string verb, string url, string filePath)
        {
            string fp = filePath != null?filePath.Replace(HttpRuntime.AppDomainAppPath, "/").Replace(Path.DirectorySeparatorChar, '/') : null;

            Type type;

            type = BuildManager.GetCompiledType(url);

            WSProtocol protocol = GuessProtocol(context, verb);

            context.Items ["WebServiceSoapVersion"] =
                protocol == WSProtocol.HttpSoap12 ?
                SoapProtocolVersion.Soap12 :
                SoapProtocolVersion.Default;
            bool         supported = false;
            IHttpHandler handler   = null;

            supported = WSConfig.IsSupported(protocol);
            if (!supported)
            {
                switch (protocol)
                {
                default:
                    if (((protocol & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown) &&
                        (WSConfig.Current.EnabledProtocols & WSProtocol.AnyHttpSoap) != WSProtocol.Unknown)
                    {
                        throw new InvalidOperationException("Possible SOAP version mismatch.");
                    }
                    break;

                case WSProtocol.HttpPost:
                    if (WSConfig.IsSupported(WSProtocol.HttpPostLocalhost))
                    {
                        supported = context.Request.IsLocal;
                    }
                    break;
                }
            }
            if (!supported)
            {
                throw new InvalidOperationException("Unsupported request format.");
            }

            switch (protocol)
            {
            case WSProtocol.HttpSoap12:
            case WSProtocol.HttpSoap:
                handler = GetTypeHandler(context, new HttpSoapWebServiceHandler(type));
                break;

            case WSProtocol.HttpPost:
            case WSProtocol.HttpGet:
                handler = GetTypeHandler(context, new HttpSimpleWebServiceHandler(type, protocol.ToString()));
                break;

            case WSProtocol.Documentation:
                SoapDocumentationHandler soapHandler;
                soapHandler = new SoapDocumentationHandler(type, context);
                if (soapHandler.PageHandler is IRequiresSessionState)
                {
                    if (soapHandler.PageHandler is IReadOnlySessionState)
                    {
                        handler = new ReadOnlySessionWrapperHandler(soapHandler);
                    }
                    else
                    {
                        handler = new SessionWrapperHandler(soapHandler);
                    }
                }
                else
                {
                    handler = soapHandler;
                }
                break;
            }

            return(handler);
        }