Example #1
0
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);

            request = buffer.CreateMessage();
            Message messageCopy = buffer.CreateMessage();

            //para obtener el metodo y la peticion del ws
            var           action        = OperationContext.Current.IncomingMessageHeaders.Action;
            var           operationName = action.Substring(action.LastIndexOf("/") + 1);
            StringWriter  stringWriter  = new StringWriter();
            XmlTextWriter xmlTextWriter = new XmlTextWriter(stringWriter);

            xmlTextWriter.Formatting  = Formatting.Indented;
            xmlTextWriter.Indentation = 1;
            xmlTextWriter.IndentChar  = '\t';
            messageCopy.WriteMessage(xmlTextWriter);


            // Read the custom context data from the headers
            ModelInterceptor requestHeaders = Header.ReadHeader(request);

            // Add an extension to the current operation context so
            // that our custom context can be easily accessed anywhere.
            //ServerContext customContext = new ServerContext();
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                Utilerias.validaUsuario(requestHeaders.usuario, requestHeaders.contrasena);
                new Logg().Info("Mensaje de Entrada: (Request) \n\n" + stringWriter.ToString());
                log4netRequest.Info("Mensaje de Entrada: (Request) \n\n" + stringWriter.ToString());
            }
            OperationContext.Current.IncomingMessageProperties.Add(
                "CurrentContext", new ModelInterceptor());
            return(null);
        }
Example #2
0
        public static ModelInterceptor ReadHeader(Message request)
        {
            ModelInterceptor header = new ModelInterceptor();

            header.usuario    = GetHeader(request, "Usuario", "");
            header.contrasena = GetHeader(request, "Contrasena", "");
            return(header);
        }