internal override SoapServerMethod RouteRequest()
        {
            string action = ContentType.GetAction(ServerProtocol.Request.ContentType);

            SoapServerMethod method = null;
            bool             duplicateAction = false, duplicateRequestElement = false;

            if (action != null && action.Length > 0)
            {
                action = HttpUtility.UrlDecode(action);
                method = ServerType.GetMethod(action);
                if (method != null)
                {
                    if (ServerType.GetDuplicateMethod(action) != null)
                    {
                        method          = null;
                        duplicateAction = true;
                    }
                }
            }

            XmlQualifiedName requestElement = new XmlQualifiedName("", "");

            if (method == null)
            {
                // try request element
                requestElement = GetRequestElement();
                method         = ServerType.GetMethod(requestElement);
                if (method != null)
                {
                    if (ServerType.GetDuplicateMethod(requestElement) != null)
                    {
                        method = null;
                        duplicateRequestElement = true;
                    }
                }
            }

            if (method == null)
            {
                // try to figure out what happened...
                if (action == null || action.Length == 0)
                {
                    // they didn't send a soap action and we couldn't route on request element
                    // require soap action for future requests:
                    throw new SoapException(Res.GetString(Res.UnableToHandleRequestActionRequired0), Soap12FaultCodes.SenderFaultCode);
                }
                else if (duplicateAction)
                {
                    // what went wrong with the request element?
                    if (duplicateRequestElement)
                    {
                        // server's fault -- nothing the client could have done to prevent this
                        throw new SoapException(Res.GetString(Res.UnableToHandleRequest0), Soap12FaultCodes.ReceiverFaultCode);
                    }
                    else
                    {
                        // probably client's fault -- we didn't recognize the request element they sent
                        throw new SoapException(Res.GetString(Res.TheRequestElementXmlnsWasNotRecognized2, requestElement.Name, requestElement.Namespace), Soap12FaultCodes.SenderFaultCode);
                    }
                }
                else
                {
                    // neither action nor request element worked out for us. since they sent an action,
                    // we'll suggest they do a better job next time
                    throw new SoapException(Res.GetString(Res.UnableToHandleRequestActionNotRecognized1, action), Soap12FaultCodes.SenderFaultCode);
                }
            }

            return(method);
        }
Ejemplo n.º 2
0
        internal override SoapServerMethod RouteRequest()
        {
            string           action = ContentType.GetAction(base.ServerProtocol.Request.ContentType);
            SoapServerMethod method = null;
            bool             flag   = false;
            bool             flag2  = false;
            TraceMethod      caller = Tracing.On ? new TraceMethod(this, "RouteRequest", new object[0]) : null;

            if ((action != null) && (action.Length > 0))
            {
                action = System.Web.HttpUtility.UrlDecode(action);
                if (Tracing.On)
                {
                    Tracing.Enter("RouteRequest", caller, new TraceMethod(base.ServerType, "GetMethod", new object[] { action }), Tracing.Details(base.ServerProtocol.Request));
                }
                method = base.ServerType.GetMethod(action);
                if (Tracing.On)
                {
                    Tracing.Exit("RouteRequest", caller);
                }
                if ((method != null) && (base.ServerType.GetDuplicateMethod(action) != null))
                {
                    method = null;
                    flag   = true;
                }
            }
            XmlQualifiedName empty = XmlQualifiedName.Empty;

            if (method == null)
            {
                empty = base.GetRequestElement();
                if (Tracing.On)
                {
                    Tracing.Enter("RouteRequest", caller, new TraceMethod(base.ServerType, "GetMethod", new object[] { empty }), Tracing.Details(base.ServerProtocol.Request));
                }
                method = base.ServerType.GetMethod(empty);
                if (Tracing.On)
                {
                    Tracing.Exit("RouteRequest", caller);
                }
                if ((method != null) && (base.ServerType.GetDuplicateMethod(empty) != null))
                {
                    method = null;
                    flag2  = true;
                }
            }
            if (method != null)
            {
                return(method);
            }
            if ((action == null) || (action.Length == 0))
            {
                throw new SoapException(System.Web.Services.Res.GetString("UnableToHandleRequestActionRequired0"), Soap12FaultCodes.SenderFaultCode);
            }
            if (flag)
            {
                if (flag2)
                {
                    throw new SoapException(System.Web.Services.Res.GetString("UnableToHandleRequest0"), Soap12FaultCodes.ReceiverFaultCode);
                }
                throw new SoapException(System.Web.Services.Res.GetString("TheRequestElementXmlnsWasNotRecognized2", new object[] { empty.Name, empty.Namespace }), Soap12FaultCodes.SenderFaultCode);
            }
            throw new SoapException(System.Web.Services.Res.GetString("UnableToHandleRequestActionNotRecognized1", new object[] { action }), Soap12FaultCodes.SenderFaultCode);
        }