Пример #1
0
 public WsMessage( WsWsaHeader header, object body, WsPrefix prefixes, WsXmlNamespaces namespaces, WsAppSequence appSequence)
 {
     this.Header      = header;
     this.Body        = body;
     this.Prefixes    = prefixes;
     this.Namespaces  = namespaces;
     this.AppSequence = appSequence;
 }
        public String WriteSoapMessageStart(XmlWriter writer, WsPrefix prefixes, WsXmlNamespaces additionalPrefixes, WsWsaHeader header, WsAppSequence appSequence, bool fSendHeader)
        {
            String messageId = "urn:uuid:" + Guid.NewGuid();

            String xml =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
                "<s:Envelope xmlns:s=\"" + WsWellKnownUri.SoapNamespaceUri + "\" " +
                "xmlns:a=\"" + m_version.AddressingNamespace + "\" ";

            if ((prefixes & WsPrefix.Wsdp) != WsPrefix.None)
            {
                xml += "xmlns:p=\"" + m_version.WsdpNamespaceUri + "\" ";
            }

            if ((prefixes & WsPrefix.Wse) != WsPrefix.None)
            {
                xml += "xmlns:e=\"" + WsWellKnownUri.WseNamespaceUri + "\" ";
            }

            if ((prefixes & WsPrefix.Wsx) != WsPrefix.None)
            {
                xml += "xmlns:x=\"" + WsWellKnownUri.WsxNamespaceUri + "\" ";
            }

            if ((prefixes & WsPrefix.Wsd) != WsPrefix.None || appSequence != null)
            {
                xml += "xmlns:d=\"" + m_version.DiscoveryNamespace + "\" ";
            }

            if (additionalPrefixes != null)
            {
                int count = additionalPrefixes.Count;
                WsXmlNamespace current;
                for (int i = 0; i < count; i++)
                {
                    current = additionalPrefixes[i];
                    xml += "xmlns:" + current.Prefix + "=\"" + current.NamespaceURI + "\" ";
                }
            }

            xml += ">";

            if(fSendHeader)
            {
                xml +=
                    "<s:Header>" +
                    "<a:Action" + (header.MustUnderstand ? " s:mustUnderstand=\"1\">" : ">") + header.Action + "</a:Action>" +
                    "<a:MessageID>" + messageId + "</a:MessageID>" +
                    "<a:To" + (header.MustUnderstand ? " s:mustUnderstand=\"1\">" : ">") + header.To + "</a:To>";

                if (header.RelatesTo != null)
                {
                    xml += "<a:RelatesTo>" + header.RelatesTo + "</a:RelatesTo>";
                }

                if (header.From != null)
                {
                    xml += "<a:From><a:Address>" + header.From.Address.AbsoluteUri + "</a:Address></a:From>";
                }

                if (header.ReplyTo != null)
                {
                    xml += "<a:ReplyTo><a:Address>" + header.ReplyTo.Address.AbsoluteUri + "</a:Address></a:ReplyTo>";
                }

                if (appSequence != null)
                {
                    xml += "<d:AppSequence InstanceId=\"" + appSequence.InstanceId + "\" ";

                    if(appSequence.SequenceId != null)
                    {
                        xml += "SequenceId=\"" + appSequence.SequenceId + "\" ";
                    }
                    
                    xml += "MessageNumber=\"" + appSequence.MessageNumber + "\"/>";
                }

                writer.WriteRaw(xml);

                if (header.Any != null)
                {
                    header.Any.WriteTo(writer);
                }

                writer.WriteRaw("</s:Header>");
            }
            else
            {
                writer.WriteRaw(xml);
            }

            writer.WriteRaw("<s:Body>");

            return messageId;
        }
Пример #3
0
 public WsMessage( WsWsaHeader header, object body, WsPrefix prefixes )
 {
     this.Header   = header;
     this.Body     = body;
     this.Prefixes = prefixes;
 }