예제 #1
0
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            writer.WriteStartElement("html");
            writer.WriteStartElement("head");
            writer.WriteElementString("title", "Request Failed");
            writer.WriteRaw(@"<style>BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; } #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; } A:link { color: #336699; font-weight: bold; text-decoration: underline; } A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; } A:active { color: #336699; font-weight: bold; text-decoration: underline; } h1 { background-color: #003366; border-bottom: #336699 6px solid; color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal;margin: 0em 0em 10px -20px; padding-bottom: 8px; padding-left: 30px;padding-top: 16px;} pre { font-size:small; background-color: #e5e5cc; padding: 5px; font-family: Courier New; margin-top: 0px; border: 1px #f0f0e0 solid; white-space: pre-wrap; white-space: -pre-wrap; word-wrap: break-word; } table { border-collapse: collapse; border-spacing: 0px; font-family: Verdana; font-size: 1em;} table th { border-right: 2px white solid; border-bottom: 2px white solid; font-weight: bold; background-color: #cecf9c;} table td { border-right: 2px white solid; border-bottom: 2px white solid; background-color: #e5e5cc;}</style>");
            writer.WriteEndElement(); //head
            writer.WriteStartElement("body");
            writer.WriteRaw("<div id='content'>");

            writer.WriteElementString("h1", "Request Failed");
            writer.WriteElementString("h3", Message);

            writer.WriteRaw("</div>");
            writer.WriteEndElement(); //body
            writer.WriteEndElement(); //html
        }
예제 #2
0
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     XmlWriterSettings setting = new XmlWriterSettings();
     setting.NewLineHandling = NewLineHandling.Entitize;
     setting.CheckCharacters = false;
     if (!string.IsNullOrEmpty(body))
     {
         writer.WriteRaw(body);
     }
     if (doc != null)
     {
         doc.WriteContentTo(writer);
         writer.Flush();
     }
 }
예제 #3
0
        /// <summary>
        /// Override the method to write the content to the xml dictionary writer.
        /// </summary>
        /// <param name="writer">Specify the output destination of the content.</param>
        protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
        {
            byte[] bytes = new byte[this.stream.Length];
            this.stream.Position = 0;
            this.stream.Read(bytes, 0, bytes.Length);
            string content = this.encoding.GetString(bytes);

            if (content.ToLowerInvariant().Contains("Content-Type: multipart/related".ToLowerInvariant()))
            {
                using (XmlDictionaryReader reader = XmlDictionaryReader.CreateMtomReader(bytes, 0, (int)bytes.Length, this.encoding, XmlDictionaryReaderQuotas.Max))
                {
                    XmlDocument msgDoc = new XmlDocument();
                    msgDoc.PreserveWhitespace = true;
                    msgDoc.Load(reader);
                    content = msgDoc.OuterXml;
                }
            }
            writer.WriteRaw(content);
        }
예제 #4
0
		public override void WriteObjectContent(XmlDictionaryWriter writer, object graph)
		{
			writer.WriteRaw(graph.ToString());
		}
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     writer.WriteRaw(_message);
 }
        public override void WriteObjectContent(XmlDictionaryWriter writer, Object graph)
        {
            string authToken = string.Format("<UserId>00000000-0000-0000-0000-000000000000</UserId><UserName>{0}</UserName><Password>{1}</Password>", _userName, _password);

            writer.WriteRaw(authToken);
        }
예제 #7
0
 public override void WriteRaw(char[] buffer, int index, int count)
 {
     writer.WriteRaw(buffer, index, count);
 }
            protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
            {
                writer.WriteRaw(GetToken().OuterXml);

                writer.WriteStartElement("Timestamp");
                writer.WriteXmlnsAttribute("", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
                writer.WriteAttributeString("Id", "Timestamp-79");
                //Created
                writer.WriteStartElement("Created");
                writer.WriteString(this.token.ValidFrom.ToString("yyyy-MM-ddTHH:mm:ssZ"));
                writer.WriteEndElement();
                //Expires
                writer.WriteStartElement("Expires");
                writer.WriteString(this.token.ValidTo.ToString("yyyy-MM-ddTHH:mm:ssZ"));
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        /// <summary>
        /// Override the method to write the content to the XML dictionary writer.
        /// </summary>
        /// <param name="writer">Specify the output destination of the content.</param>
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            MemoryStream ms = new MemoryStream();
            XmlSerializer serializer = new XmlSerializer(typeof(EnvelopeBody));
            serializer.Serialize(ms, this.requestEnvelope);

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(System.Text.ASCIIEncoding.ASCII.GetString(ms.ToArray(), 0, ms.ToArray().Length));
            ms.Dispose();
            foreach (XmlNode node in doc.LastChild.ChildNodes)
            {
                if (node.Name == "RequestVersion")
                {
                    writer.WriteRaw(node.OuterXml);
                }
                else if (node.Name == "RequestCollection")
                {
                    this.WriteNode(node, writer);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("this element [{0}] is not expected element", node.Name));
                }
            }
        }