public void WriteJson(XmlDictionaryWriter writer)
            {
                writer.WriteStartElement(MetadataStrings.TypeString);
                writer.WriteAttributeString("type", "string");
                writer.WriteString(String.Format("{0}{1}{2}", this.TypeName, MetadataStrings.NamespaceMarker, this.TypeNamespace));
                writer.WriteEndElement();

                writer.WriteStartElement(MetadataStrings.KeyString);
                writer.WriteAttributeString("type", "array");
                foreach (string keyitem in this.Key)
                {
                    writer.WriteStartElement("item");
                    writer.WriteAttributeString("type", "string");
                    writer.WriteValue(keyitem);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();

                writer.WriteStartElement(MetadataStrings.FieldsString);
                writer.WriteAttributeString("type", "object");
                foreach (TypePropertyMetadata field in this.Properties)
                {
                    field.WriteJson(writer);
                }
                writer.WriteEndElement();

                this.WriteValidationRulesMetadata(writer);
            }
 protected override void OnWriteStartAddressHeader(XmlDictionaryWriter writer)
 {
     XmlDictionaryReader addressHeaderReader = this.GetAddressHeaderReader();
     writer.WriteStartElement(addressHeaderReader.Prefix, addressHeaderReader.LocalName, addressHeaderReader.NamespaceURI);
     writer.WriteAttributes(addressHeaderReader, false);
     addressHeaderReader.Close();
 }
Beispiel #3
0
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     using (XmlWriterBackedStream stream = new XmlWriterBackedStream(writer))
     {
         OnWriteBodyContents(stream);
     }
 }
Beispiel #4
0
		protected virtual void AddPrefixIfNeeded(XmlDictionaryWriter writer, string prefix, string ns)
		{
			if (writer.LookupPrefix(ns) == null)
			{
				writer.WriteXmlnsAttribute(prefix, ns);
			}
		}
        internal override void WriteContentsTo(XmlDictionaryWriter writer)
        {
            if (writer == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");

            writer.WriteElementString(XD.AddressingDictionary.Dns, XD.AddressingDictionary.IdentityExtensionNamespace, (string)this.IdentityClaim.Resource);
        }
 /// <summary>
 /// Writes the body of an object in the output
 /// </summary>
 public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     if (graph == null)
     {
         writer.WriteAttributeString("nil", "true");
     }
     else
     {
         using (MemoryStream ms = new MemoryStream())
         {
             if (isList)
             {
                 model.Serialize(ms, graph, null);
             }
             else
             {
                 using (ProtoWriter protoWriter = new ProtoWriter(ms, model, null))
                 {
                     model.Serialize(key, graph, protoWriter);
                 }
             }
             byte[] buffer = ms.GetBuffer();
             writer.WriteBase64(buffer, 0, (int)ms.Length);
         }
     }
 }
Beispiel #7
0
		protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
		{
			writer.WriteStartElement("Renew", "http://schemas.xmlsoap.org/ws/2004/09/enumeration");
			XmlUtility.SerializeEnumerationContext(writer, this._enumerationContext);
			XmlUtility.SerializeExpires(writer, this._expirationDateTime, this._expirationTimeSpan);
			writer.WriteEndElement();
		}
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
     XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(this.reliableMessagingVersion);
     writer.WriteStartElement(dictionary.CreateSequenceResponse, namespaceUri);
     writer.WriteStartElement(dictionary.Identifier, namespaceUri);
     writer.WriteValue(this.identifier);
     writer.WriteEndElement();
     if (this.expires.HasValue)
     {
         writer.WriteStartElement(dictionary.Expires, namespaceUri);
         writer.WriteValue(this.expires.Value);
         writer.WriteEndElement();
     }
     if (this.reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
     {
         Wsrm11Dictionary dictionary2 = DXD.Wsrm11Dictionary;
         writer.WriteStartElement(dictionary2.IncompleteSequenceBehavior, namespaceUri);
         writer.WriteValue(this.ordered ? dictionary2.DiscardFollowingFirstGap : dictionary2.NoDiscard);
         writer.WriteEndElement();
     }
     if (this.acceptAcksTo != null)
     {
         writer.WriteStartElement(dictionary.Accept, namespaceUri);
         this.acceptAcksTo.WriteTo(this.addressingVersion, writer, dictionary.AcksTo, namespaceUri);
         writer.WriteEndElement();
     }
     writer.WriteEndElement();
 }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     using (XmlWriterBackedStream stream = new XmlWriterBackedStream(writer, this.isQuirkedTo40Behavior))
     {
         OnWriteBodyContents(stream);
     }
 }
        public SamlDelegatingWriter(XmlDictionaryWriter innerWriter, Stream canonicalStream, ICanonicalWriterEndRootElementCallback callback, IXmlDictionary dictionary)
        {
            if (innerWriter == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("innerWriter");

            if (canonicalStream == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("canonicalStream");

            if (callback == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("callback");

            if (dictionary == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionary");

            this.innerWriter = innerWriter;
            this.canonicalStream = canonicalStream;
            this.callback = callback;
            this.dictionary = dictionary;
            this.elementCount = 0;

            this.startFragment = new MemoryStream();
            this.signatureFragment = new MemoryStream();
            this.endFragment = new MemoryStream();
            this.writerStream = new MemoryStream();

            this.effectiveWriter = XmlDictionaryWriter.CreateBinaryWriter(this.writerStream, this.dictionary);
            this.effectiveWriter.StartCanonicalization(this.canonicalStream, false, null);
            ((IFragmentCapableXmlDictionaryWriter)this.effectiveWriter).StartFragment(this.startFragment, false);
        }
        public XmlDelegatedWriter(XmlDictionaryWriter writer)
        {
            if (writer == null)
                throw System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("writer"));

            this.writer = writer;
        }
Beispiel #12
0
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     WebUtil.CheckArgumentNull<XmlDictionaryWriter>(writer, "writer");
     try
     {
         writer.WriteStartElement("Binary");
         using (XmlWriterStream stream = new XmlWriterStream(writer))
         {
             this.writerAction(stream);
         }
         writer.WriteEndElement();
     }
     finally
     {
         if (this.service != null)
         {
             this.service.DisposeDataSource();
             HttpContextServiceHost httpContextServiceHost = this.service.OperationContext.Host.HttpContextServiceHost;
             if ((httpContextServiceHost != null) && httpContextServiceHost.ErrorFound)
             {
                 OperationContext current = OperationContext.Current;
                 if (current != null)
                 {
                     current.Channel.Abort();
                 }
             }
         }
     }
 }
 public override void WriteEndObject(XmlDictionaryWriter writer)
 {
     if (!skipName)
     {
         writer.WriteEndElement();
     }
 }
 private void CheckIfEndContentTypeAttribute()
 {
     if (this.contentTypeStream != null)
     {
         this.Writer.WriteEndAttribute();
         this.Writer.WriteEndElement();
         this.Writer.Flush();
         this.contentTypeStream.Position = 0L;
         XmlReader reader = XmlDictionaryReader.CreateBinaryReader(this.contentTypeStream, null, XmlDictionaryReaderQuotas.Max, null, null);
         while (reader.Read())
         {
             if (reader.IsStartElement("Wrapper"))
             {
                 this.contentType = reader.GetAttribute(MtomGlobals.MimeContentTypeLocalName, MtomGlobals.MimeContentTypeNamespace200406);
                 if (this.contentType == null)
                 {
                     this.contentType = reader.GetAttribute(MtomGlobals.MimeContentTypeLocalName, MtomGlobals.MimeContentTypeNamespace200505);
                 }
                 break;
             }
         }
         this.writer = this.infosetWriter;
         this.infosetWriter = null;
         this.contentTypeStream = null;
         if (this.contentType != null)
         {
             this.Writer.WriteString(this.contentType);
         }
     }
 }
Beispiel #15
0
 internal void Serialize(XmlDictionaryWriter writer, object[] parameters, object returnValue)
 {
     Stream streamValue = GetStreamAndWriteStartWrapperIfNecessary(writer, parameters, returnValue);
     var streamProvider = new OperationStreamProvider(streamValue);
     StreamFormatterHelper.WriteValue(writer, streamProvider);
     WriteEndWrapperIfNecessary(writer);
 }
        private void WriteHeader(XmlDictionaryWriter writer)
        {
            var nonce = new byte[64];
            RandomNumberGenerator.Create().GetBytes(nonce);
            string created = DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss.msZ");

            writer.WriteStartElement("wsse", "UsernameToken", null);
            writer.WriteAttributeString("wsu:Id", "UsernameToken-1");
            writer.WriteStartElement("wsse", "Username", null);
            writer.WriteString(SystemUser);
            writer.WriteEndElement();//End Username
            writer.WriteStartElement("wsse", "Password", null);
            writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
            writer.WriteString(ComputePasswordDigest(SystemPassword, nonce, created));
            writer.WriteEndElement();//End Password
            writer.WriteStartElement("wsse", "Nonce", null);
            writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
            writer.WriteBase64(nonce, 0, nonce.Length);
            writer.WriteEndElement();//End Nonce
            writer.WriteStartElement("wsu", "Created", null);
            writer.WriteString(created);
            writer.WriteEndElement();//End Created
            writer.WriteEndElement();//End UsernameToken
            writer.Flush();
        }
        /// <summary>Called when the message body is written to an XML file.</summary>
        /// <param name="writer">
        /// An <see cref="XmlDictionaryWriter"/> that is used to write this 
        /// message body to an XML file.
        /// </param>
        protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
        {
            WebUtil.CheckArgumentNull(writer, "writer");

            try
            {
                writer.WriteStartElement(XmlConstants.WcfBinaryElementName);
                using (XmlWriterStream stream = new XmlWriterStream(writer))
                {
                    this.writerAction(stream);
                }

                writer.WriteEndElement();
            }
            finally
            {
                if (this.service != null)
                {
                    HttpContextServiceHost host = this.service.OperationContext.RequestMessage.HttpContextServiceHost;

                    this.service.DisposeDataSource();
                    if (host != null)
                    {
                        if (host.ErrorFound)
                        {
                            var ctx = System.ServiceModel.OperationContext.Current;
                            if (ctx != null)
                            {
                                ctx.Channel.Abort();
                            }
                        }
                    }
                }
            }
        }
Beispiel #18
0
        private static void DumpEncoderSize(System.Xml.XmlDictionaryWriter writer, Message copy)
        {
            var ms = new MemoryStream();

            string configuredEncoder = string.Empty;

            if (writer is IXmlTextWriterInitializer)
            {
                var w = (IXmlTextWriterInitializer)writer;
                w.SetOutput(ms, Encoding.UTF8, true);
                configuredEncoder = "Text";
            }
            else if (writer is IXmlMtomWriterInitializer)
            {
                var w = (IXmlMtomWriterInitializer)writer;
                w.SetOutput(ms, Encoding.UTF8, int.MaxValue, "", null, null, true, false);
                configuredEncoder = "MTOM";
            }
            else if (writer is IXmlBinaryWriterInitializer)
            {
                var w = (IXmlBinaryWriterInitializer)writer;
                w.SetOutput(ms, null, null, false);
                configuredEncoder = "Binary";
            }

            copy.WriteMessage(writer);
            writer.Flush();
            var size = ms.Position;

            Console.WriteLine("Message size using configured ({1}) encoder {0}", size, configuredEncoder);
        }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     lock (this.ThisLock)
     {
         this.serializer.WriteObject(writer, this.body);
     }
 }
Beispiel #20
0
 void WriteChunkCallback(XmlDictionaryWriter writer, object state)
 {
     ChunkState chunkState = (ChunkState)state;
     writer.WriteStartElement(ChunkingUtils.ChunkElement, ChunkingUtils.ChunkNs);
     writer.WriteBase64(chunkState.Buffer, 0, chunkState.Count);
     writer.WriteEndElement();
 }
 internal static void WriteAckRanges(XmlDictionaryWriter writer, ReliableMessagingVersion reliableMessagingVersion, UniqueId sequenceId, SequenceRangeCollection ranges)
 {
     WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
     XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
     writer.WriteStartElement(dictionary.Identifier, namespaceUri);
     writer.WriteValue(sequenceId);
     writer.WriteEndElement();
     if (ranges.Count == 0)
     {
         if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
         {
             ranges = ranges.MergeWith((long) 0L);
         }
         else if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
         {
             writer.WriteStartElement(DXD.Wsrm11Dictionary.None, namespaceUri);
             writer.WriteEndElement();
         }
     }
     for (int i = 0; i < ranges.Count; i++)
     {
         writer.WriteStartElement(dictionary.AcknowledgementRange, namespaceUri);
         writer.WriteStartAttribute(dictionary.Lower, null);
         SequenceRange range = ranges[i];
         writer.WriteValue(range.Lower);
         writer.WriteEndAttribute();
         writer.WriteStartAttribute(dictionary.Upper, null);
         SequenceRange range2 = ranges[i];
         writer.WriteValue(range2.Upper);
         writer.WriteEndAttribute();
         writer.WriteEndElement();
     }
 }
        protected override void OnWriteAddressHeaderContents (XmlDictionaryWriter writer)
        {
            writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId,
                                     XD.DotNetAtomicTransactionExternalDictionary.Namespace);

            writer.WriteValue(this.transactionId);
            writer.WriteEndElement();

            if (this.contextId != null)
            {
                writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId,
                                         XD.DotNetAtomicTransactionExternalDictionary.Namespace);

                writer.WriteValue(this.contextId);
                writer.WriteEndElement();
            }

            if (this.tokenId != null)
            {
                writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId,
                                         XD.DotNetAtomicTransactionExternalDictionary.Namespace);

                writer.WriteValue(this.tokenId);
                writer.WriteEndElement();
            }
        }
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     if (this.data != int.MinValue)
     {
         writer.WriteElementString("ID", this.data.ToString());
     }
 }
 protected override void WriteAdditionalAttributes(XmlDictionaryWriter writer)
 {
     if (this.recipient != null)
     {
         writer.WriteAttributeString(RecipientAttribute, null, this.recipient);
     }
 }
Beispiel #25
0
 public override void WriteObject(XmlDictionaryWriter writer, object graph)
 {
     var data = EncodeObject(graph);
     writer.WriteStartElement("Data");
     writer.WriteBase64(data, 0, data.Length);
     writer.WriteEndElement();
 }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     if (_data != null && _data.Length > 0)
     {
         writer.WriteElementString("BODY", _data);
     }
 }
 public override void WriteObject(XmlDictionaryWriter writer, object graph)
 {
     if (_isSerializerSetExplicit)
         _serializer.Serialize(writer, new object[] { graph });
     else
         _serializer.Serialize(writer, graph);
 }
 protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
 {
     writer.WriteStartElement("Binary");
     byte[] buffer = JSONPSupportInspector.encoding.GetBytes(this.content);
     writer.WriteBase64(buffer, 0, buffer.Length);
     writer.WriteEndElement();
 }
Beispiel #29
0
 internal async Task SerializeAsync(XmlDictionaryWriter writer, object[] parameters, object returnValue)
 {
     Stream streamValue = await GetStreamAndWriteStartWrapperIfNecessaryAsync(writer, parameters, returnValue);
     var streamProvider = new OperationStreamProvider(streamValue);
     await StreamFormatterHelper.WriteValueAsync(writer, streamProvider);
     await WriteEndWrapperIfNecessaryAsync(writer);
 }
 public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
 {
     EncryptedKeyIdentifierClause clause = keyIdentifierClause as EncryptedKeyIdentifierClause;
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptedKey, this.NamespaceUri);
     if (clause.EncryptionMethod != null)
     {
         writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptionMethod, this.NamespaceUri);
         writer.WriteAttributeString(XD.XmlEncryptionDictionary.AlgorithmAttribute, null, clause.EncryptionMethod);
         if (clause.EncryptionMethod == XD.SecurityAlgorithmDictionary.RsaOaepKeyWrap.Value)
         {
             writer.WriteStartElement("", XD.XmlSignatureDictionary.DigestMethod, XD.XmlSignatureDictionary.Namespace);
             writer.WriteAttributeString(XD.XmlSignatureDictionary.Algorithm, null, "http://www.w3.org/2000/09/xmldsig#sha1");
             writer.WriteEndElement();
         }
         writer.WriteEndElement();
     }
     if (clause.EncryptingKeyIdentifier != null)
     {
         this.tokenSerializer.WriteKeyIdentifier(writer, clause.EncryptingKeyIdentifier);
     }
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherData, this.NamespaceUri);
     writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherValue, this.NamespaceUri);
     byte[] encryptedKey = clause.GetEncryptedKey();
     writer.WriteBase64(encryptedKey, 0, encryptedKey.Length);
     writer.WriteEndElement();
     writer.WriteEndElement();
     if (clause.CarriedKeyName != null)
     {
         writer.WriteElementString(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CarriedKeyName, this.NamespaceUri, clause.CarriedKeyName);
     }
     writer.WriteEndElement();
 }
Beispiel #31
0
		internal static void Serialize(MessageDictionary messageDictionary, XmlDictionaryWriter writer) {
			Requires.NotNull(messageDictionary, "messageDictionary");
			Requires.NotNull(writer, "writer");

			writer.WriteStartElement("root");
			writer.WriteAttributeString("type", "object");
			foreach (var pair in messageDictionary) {
				bool include = false;
				string type = "string";
				MessagePart partDescription;
				if (messageDictionary.Description.Mapping.TryGetValue(pair.Key, out partDescription)) {
					Contract.Assume(partDescription != null);
					if (partDescription.IsRequired || partDescription.IsNondefaultValueSet(messageDictionary.Message)) {
						include = true;
						if (IsNumeric(partDescription.MemberDeclaredType)) {
							type = "number";
						} else if (partDescription.MemberDeclaredType.IsAssignableFrom(typeof(bool))) {
							type = "boolean";
						}
					}
				} else {
					// This is extra data.  We always write it out.
					include = true;
				}

				if (include) {
					writer.WriteStartElement(pair.Key);
					writer.WriteAttributeString("type", type);
					writer.WriteString(pair.Value);
					writer.WriteEndElement();
				}
			}

			writer.WriteEndElement();
		}
		Hashtable references = new Hashtable (); // preserve possibly referenced objects to ids. (new in 3.5 SP1)

		public static void Serialize (XmlDictionaryWriter writer, object graph,
			KnownTypeCollection types,
			bool ignoreUnknown, int maxItems, string root_ns)
		{
			new XmlFormatterSerializer (writer, types, ignoreUnknown, maxItems, root_ns)
				.Serialize (graph != null ? graph.GetType () : null, graph);
		}
        public void ApplySecurityAndWriteHeaders(MessageHeaders headers, XmlDictionaryWriter writer, SecurityIdGenerator securityIdGenerator)
        {
            // There is no way to look through the headers attributes without changing the way
            // Headers.WriterStartHeader / headers.writeHeadercontents writes the header
            // So i'm using a copy that I can change without worries.
            MessageHeaders copyHeaders = new MessageHeaders(headers);

            for (int i = 0; i < headers.Count; i++)
            {
                MessageHeaderInfo header = headers[i];

                // We are not supporting another d:Security header, throw if there is already one in the message
                if (this.IsSecurityElement(header))
                {
                    throw new ArgumentException("The message already contains a d:security header.");
                }

                if (this.ShouldProtectHeader(header))
                {
                    string headerId;
                    bool idInserted;
                    this.GetHeaderId(copyHeaders.GetReaderAtHeader(i), securityIdGenerator, true, out headerId, out idInserted);

                    // Add a reference for this header
                    this.signer.AddReference(headers, i, writer, headerId, idInserted);
                }
                else
                {
                    headers.WriteHeader(i, writer);
                }
            }
        }
 protected override void OnWriteHeaderContents(System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     writer.WriteElementString(VeriBranchMessageHeaderNames.IsSuccess, this.IsSuccess.ToString().ToLower());
     writer.WriteElementString(VeriBranchMessageHeaderNames.Description, this.Description);
     writer.WriteElementString(VeriBranchMessageHeaderNames.DisplayMessage, this.DisplayMessage);
     writer.WriteElementString(VeriBranchMessageHeaderNames.ErrorCode, this.ErrorCode);
     writer.WriteElementString(VeriBranchMessageHeaderNames.ExceptionMessage, this.ExceptionMessage);
 }
 /// <summary>
 /// Ends an object in the output
 /// </summary>
 public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     writer.WriteEndElement();
 }
 /// <summary>
 /// Begins an object in the output
 /// </summary>
 public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     if (writer == null)
     {
         throw new ArgumentNullException("writer");
     }
     writer.WriteStartElement(PROTO_ELEMENT);
 }
        /// <summary>
        /// Write the content of <paramref name="graph"/> onto <paramref name="writer"/>.
        /// </summary>
        /// <param name="writer">The writer to serialize <paramref name="graph"/>.</param>
        /// <param name="graph">The object to graph to <paramref name="writer"/>.</param>
        public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph)
        {
            XmlStateWriter xsw    = new XmlStateWriter(writer as XmlWriter);
            var            result = Formatter.Graph(xsw, (IGraphable)graph);

            this.Details    = result.Details;
            this.ResultCode = result.Code;
        }
Beispiel #38
0
        protected override void OnWriteHeaderContents(
            System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(ServiceHeader));
            StringWriter  textWriter = new StringWriter();

            serializer.Serialize(textWriter, _customData);
            textWriter.Close();

            string text = textWriter.ToString();

            writer.WriteElementString(CUSTOM_HEADER_NAME, "Key", text.Trim());
        }
Beispiel #39
0
            protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
            {
                // TODO:  RawMessageEncoder.StreamElementName should be public.
                writer.WriteStartElement("Binary");  // the expected Raw encoder "<Binary>" virtual xml tag

                if (bodyAsString != null)
                {
                    byte[] buf = Encoding.UTF8.GetBytes(bodyAsString);
                    writer.WriteBase64(buf, 0, buf.Length);
                }
                else
                {
                    writer.WriteBase64(this.bodyAsBytes, this.offset, this.count);
                }

                writer.WriteEndElement();
            }
Beispiel #40
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);
        }
Beispiel #41
0
        protected override void OnWriteMessage(System.Xml.XmlDictionaryWriter writer)
        {
            //Pre sign


            //Sign
            MemoryStream stream    = new MemoryStream();
            XmlWriter    tmpWriter = new XmlTextWriter(stream, Encoding.UTF8);

            msg.WriteMessage(tmpWriter);
            tmpWriter.Flush();

            //Post sign
            stream.Position = 0;
            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;
            doc.Load(stream);
            stream.Close();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("s", "http://schemas.xmlsoap.org/soap/envelope/");
            nsmgr.AddNamespace("wssu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd");
            nsmgr.AddNamespace("wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd");
            nsmgr.AddNamespace("dsig", "http://www.w3.org/2000/09/xmldsig#");
            XmlNode referenceUri = doc.SelectSingleNode("//wsse:SecurityTokenReference/wsse:Reference/@URI", nsmgr);

            if (referenceUri != null)
            {
                XmlNode referensedToken     = doc.SelectSingleNode(String.Format("//wsse:BinarySecurityToken[@wssu:Id='{0}']", referenceUri.Value.Substring(1)), nsmgr);
                XmlNode unreferensedTokenId = doc.SelectSingleNode(String.Format("//wsse:BinarySecurityToken[@wssu:Id!='{0}']/@wssu:Id", referenceUri.Value.Substring(1)), nsmgr);
                if (unreferensedTokenId != null)
                {
                    referenceUri.Value = "#" + unreferensedTokenId.Value;
                    referensedToken.ParentNode.RemoveChild(referensedToken);
                }
            }
            doc.Save(writer);
        }
Beispiel #42
0
        protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter xmlWriter)
        {
            /* What the message should look like...
             *
             * <SaveGigRequest xmlns="http://www.thatindigogirl.com/samples/2006/06">
             * <Item xmlns:b="http://schemas.thatindigogirl.com/samples/2006/06" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
             * <b:Id>xs:int</b:Id>
             * <b:Title>xs:string</b:Title>
             * <b:Description>xs:string</b:Description>
             * <b:DateStart>xs:dateTime</b:DateStart>
             * <b:DateEnd>xs:dateTime</b:DateEnd>
             * <b:Url>xs:string</b:Url>
             * </Item>
             * </SaveGigRequest>
             */

            xmlWriter.WriteStartElement("SaveGigRequest", ns);
            xmlWriter.WriteStartElement("Item", ns);

            LinkItemHelper.WriteLinkItem(this.m_linkItem, xmlWriter);

            xmlWriter.WriteEndElement(); //Item
            xmlWriter.WriteEndElement(); //GetGigResponse
        }
Beispiel #43
0
 protected abstract void WriteArray(XmlDictionaryWriter writer, string prefix, TArgument localName, TArgument namespaceUri, TArray[] array, int offset, int count);
 protected override void WriteArray(XmlDictionaryWriter writer, string prefix, string localName, string namespaceUri, int[] array, int offset, int count)
 {
     writer.WriteArray(prefix, localName, namespaceUri, array, offset, count);
 }
 public XmlDictionaryAsyncCheckWriter(XmlDictionaryWriter writer)
 {
     _coreWriter = writer;
 }
 /// <summary>
 /// Not Implemented: The formatter does not make a distinction between the start and end of an object.
 /// </summary>
 public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     // Nothing to do
 }
Beispiel #47
0
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     m_Serializer.WriteXml(m_Rst, writer, new WSTrustSerializationContext());
 }
 /// <summary>
 /// Not Implemented: The formatter does not make a distinction between the start and end of an object.
 /// </summary>
 public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer)
 {
     // Nothing to do
 }
Beispiel #49
0
 protected override void OnWriteHeaderContents(System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     writer.WriteString(value);
 }
 /// <summary>
 /// Begins an object in the output
 /// </summary>
 public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     writer.WriteStartElement(PROTO_ELEMENT);
 }
 /// <summary>
 /// Ends an object in the output
 /// </summary>
 public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer)
 {
     writer.WriteEndElement();
 }
Beispiel #52
0
 protected override void OnWriteBodyContents(System.Xml.XmlDictionaryWriter writer)
 {
     msg.WriteBodyContents(writer);
 }
Beispiel #53
0
 public override void WriteEndObject(System.Xml.XmlDictionaryWriter writer)
 {
     // All content written in WriteObjectContent
 }
Beispiel #54
0
 public override void WriteObjectContent(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     this._writeContent(writer, graph as T);
 }
Beispiel #55
0
 public XmlDictionaryAsyncCheckWriter(XmlDictionaryWriter writer)
 {
     Debug.Assert(writer is IXmlTextWriterInitializer);
     _coreWriter = writer;
 }
Beispiel #56
0
 protected override void OnWriteHeaderContents(System.Xml.XmlDictionaryWriter writer, MessageVersion messageVersion)
 {
     //writer.WriteStartElement(this.Name, this.Namespace);
     writer.WriteValue(this.id);
     //writer.WriteEndElement();
 }
Beispiel #57
0
 public override void WriteStartObject(System.Xml.XmlDictionaryWriter writer, object graph)
 {
     // All content written in WriteObjectContent
 }