Exemplo n.º 1
0
        /// <summary>
        /// Constructs an FpML message builds the message header, if possible
        /// copying data from the original input message.
        /// </summary>
        /// <param name="release">he FpML release to respond with.</param>
        /// <param name="rootElement">The name of the root element.</param>
        /// <param name="context">Identifies the user.</param>
        /// <param name="document">The parsed form of the input messsage or <b>null</b>.</param>
        /// <returns></returns>
        private Builder CreateMessage(SchemaRelease release, string rootElement,
                                      UserContext context, XmlDocument document)
        {
            Builder builder = new HandCoded.FpML.Xml.Builder(release.NewInstance(rootElement));

            builder.AppendElement("header");
            builder.AppendElement("messageId");
            builder.SetAttribute("messageIdScheme", "urn:handcoded:message-id");
            builder.AppendText(Guid.NewGuid().ToString());
            builder.CloseElement();

            if (document != null)
            {
                XmlElement messageId = (XmlElement)XPath.Path(document.DocumentElement, "header", "messageId");
                if (messageId != null)
                {
                    builder.AppendElement("inReplyTo");
                    builder.SetAttribute("messageIdScheme", messageId.GetAttribute("messageIdScheme"));
                    builder.AppendText(Types.ToString(messageId));
                    builder.CloseElement();
                }
            }

            builder.AppendElement("sentBy");
            builder.SetAttribute("messageAddressScheme", "urn:handcoded:message-address");
            builder.AppendText("FpMLWebServiceDemo");
            builder.CloseElement();

            builder.AppendElement("sendTo");
            builder.SetAttribute("messageAddressScheme", "urn:handcoded:message-address");
            builder.AppendText(context.Username);
            builder.CloseElement();

            builder.AppendElementAndText("creationTimestamp",
                                         HandCoded.Finance.DateTime.Now(true).ToString());

            builder.CloseElement();

            return(builder);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Constructs a <b>Builder</b> instance attached the root element of
 /// a new FpML document of the given <see cref="SchemaRelease"/>.
 /// </summary>
 /// <param name="release">The FpML <see cref="SchemaRelease"/> to construct.</param>
 public Builder(SchemaRelease release)
     : base(release.NewInstance("FpML"))
 {
 }