상속: IHttpHandler, IRequiresSessionState
예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
		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;
#if NET_2_0
			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)
		{
			Type type = WebServiceParser.GetCompiledType (filePath, context);

			WSProtocol protocol = GuessProtocol (context, verb);
			bool supported = false;
			IHttpHandler handler = null;

			supported = WSConfig.IsSupported (protocol);
			if (!supported) {
				switch (protocol) {
					case WSProtocol.HttpSoap:
						supported = WSConfig.IsSupported (WSProtocol.HttpSoap12);
						break;
					case WSProtocol.HttpPost:
						if (WSConfig.IsSupported (WSProtocol.HttpPostLocalhost)) {
							string localAddr = context.Request.ServerVariables ["LOCAL_ADDR"];

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

			switch (protocol) {
			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;
		}