Esempio n. 1
0
        public string ViajesXML()
        {
            ILogicaViaje LViaje       = FabricaLogica.GetLogicaViajes();
            List <Viaje> ListarViajes = LViaje.Listar();

            XmlDocument DocumentoXML = new XmlDocument();
            XmlNode     NodoV        = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", "");

            try
            {
                foreach (Viaje V in ListarViajes)
                {
                    XmlNode NodoViaje = DocumentoXML.CreateNode(XmlNodeType.Element, "Viaje", "");

                    XmlNode NodoNum = DocumentoXML.CreateNode(XmlNodeType.Element, "Numero", "");
                    NodoNum.InnerText = V._NumViaje.ToString();
                    NodoViaje.AppendChild(NodoNum);

                    XmlNode NodoCiudad = DocumentoXML.CreateNode(XmlNodeType.Element, "CiudadDestino", "");
                    NodoCiudad.InnerText = V._Ter._Ciudad;
                    NodoViaje.AppendChild(NodoCiudad);

                    XmlNode NodoPais = DocumentoXML.CreateNode(XmlNodeType.Element, "PaisDestino", "");
                    NodoPais.InnerText = V._Ter._Pais;
                    NodoViaje.AppendChild(NodoPais);

                    XmlNode NodoCompañia = DocumentoXML.CreateNode(XmlNodeType.Element, "Compañia", "");
                    NodoCompañia.InnerText = V._Com._Nombre;
                    NodoViaje.AppendChild(NodoCompañia);

                    XmlNode NodoFecha = DocumentoXML.CreateNode(XmlNodeType.Element, "FechaPartida", "");
                    NodoFecha.InnerText = V._FechaPartida.ToString();;
                    NodoViaje.AppendChild(NodoFecha);

                    NodoV.AppendChild(NodoViaje);
                }
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
            DocumentoXML.AppendChild(NodoV);

            return(DocumentoXML.OuterXml);
        }
Esempio n. 2
0
        public List <Viaje> ListarViajes()
        {
            try
            {
                ILogicaViaje LViaje = FabricaLogica.GetLogicaViajes();
                return(LViaje.Listar());
            }
            catch (Exception ex)
            {
                XmlDocument _undoc       = new System.Xml.XmlDocument();
                XmlNode     _NodoError   = _undoc.CreateNode(XmlNodeType.Element, SoapException.DetailElementName.Name, SoapException.DetailElementName.Namespace);
                XmlNode     _NodoDetalle = _undoc.CreateNode(XmlNodeType.Element, "Error", ex.Message);

                _NodoDetalle.InnerText = ex.Message;
                _NodoError.AppendChild(_NodoDetalle);
                SoapException _MiEx = new SoapException("Error WS", SoapException.ClientFaultCode, Context.Request.Url.AbsoluteUri, _NodoError);
                throw _MiEx;
            }
        }