当前位置: 首页>>代码示例>>C#>>正文


C# WsWsaHeader.ParseHeader方法代码示例

本文整理汇总了C#中Ws.Services.WsaAddressing.WsWsaHeader.ParseHeader方法的典型用法代码示例。如果您正苦于以下问题:C# WsWsaHeader.ParseHeader方法的具体用法?C# WsWsaHeader.ParseHeader怎么用?C# WsWsaHeader.ParseHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ws.Services.WsaAddressing.WsWsaHeader的用法示例。


在下文中一共展示了WsWsaHeader.ParseHeader方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseSoapMessage

        public static XmlReader ParseSoapMessage(byte[] soapMessage, out WsWsaHeader header)
        {
            MemoryStream requestStream = new MemoryStream(soapMessage);
            XmlReader reader = XmlReader.Create(requestStream);
            header = new WsWsaHeader();

            try
            {
                reader.ReadStartElement("Envelope", WsWellKnownUri.SoapNamespaceUri);
#if DEBUG
                int depth = reader.Depth;
#endif
                header.ParseHeader(reader);
#if DEBUG
                Microsoft.SPOT.Debug.Assert(XmlReaderHelper.HasReadCompleteNode(depth, reader));
#endif
                reader.ReadStartElement("Body", WsWellKnownUri.SoapNamespaceUri);

            }
            catch (XmlException e)
            {
                reader.Close();
                throw new WsFaultException(header, WsFaultType.XmlException, e.ToString());
            }

            return reader;
        }
开发者ID:prabby,项目名称:miniclr,代码行数:27,代码来源:WsUtilities.cs

示例2: OnProcessInputMessage

        /// <summary>
        /// Processes a message
        /// </summary>
        /// <param name="stream">The message being processed.</param>
        /// <param name="ctx">The context associated with the message.</param>
        /// <returns>The handling status for this operation.</returns>
        protected override ChainResult OnProcessInputMessage(ref WsMessage msg, BindingContext ctx)
        {
            if(msg == null) return ChainResult.Abort;
            
            ArrayList props = ctx.BindingProperties;
            if (props != null)
            {
                int len = props.Count;

                for (int j = 0; j < len; j++)
                {
                    BindingProperty prop = (BindingProperty)props[j];

                    if (prop.Name == HttpKnownHeaderNames.ContentType)
                    {
                        string strContentType = ((string)prop.Value).ToLower();

                        if (strContentType.IndexOf("multipart/related;") == 0)
                        {
                            // Create the mtom header class
                            msg.MtomPropeties = new WsMtomParams();

                            // Parse Mtom Content-Type parameters
                            string[] fields = strContentType.Substring(18).Split(';');
                            int fieldsLen = fields.Length;
                            for (int i = 0; i < fieldsLen; ++i)
                            {
                                string type = fields[i];
                                int idx = type.IndexOf('=');

                                if(idx != -1)
                                {
                                    string param = type.Substring(0, idx).Trim();
                                    string value = type.Substring(idx + 1).Trim('\"');
                                    switch (param.ToUpper())
                                    {
                                        case "BOUNDARY":
                                            if (param.Length > 72)
                                                throw new ArgumentException("Mime boundary element length exceeded.", "boundary");
                                            msg.MtomPropeties.boundary = value;
                                            break;
                                        case "TYPE":
                                            msg.MtomPropeties.type = value;
                                            break;
                                        case "START":
                                            msg.MtomPropeties.start = value;
                                            break;
                                        case "START-INFO":
                                            msg.MtomPropeties.startInfo = value;
                                            break;
                                        default:
                                            break;
                                    }
                                }
                            }

                            // Check required Mtom fields
                            if (msg.MtomPropeties.boundary == null || msg.MtomPropeties.type == null || msg.MtomPropeties.start == null)
                            {
                                throw new WsFaultException(msg.Header, WsFaultType.WseInvalidMessage);
                            }

                            WsMtom mtom = new WsMtom((byte[])msg.Body);

                            msg.Body = mtom.ParseMessage(msg.MtomPropeties.boundary);
                            msg.BodyParts = mtom.BodyParts;
                        }
                        else if (strContentType.IndexOf("application/soap+xml") != 0)
                        {
                            throw new WsFaultException(msg.Header, WsFaultType.WseInvalidMessage);
                        }
                    }
                }
            }

            if (msg.Body == null) return ChainResult.Continue;

            MemoryStream requestStream = new MemoryStream((byte[])msg.Body);

            XmlReader reader = XmlReader.Create(requestStream);
            WsWsaHeader hdr = new WsWsaHeader();

            reader.ReadStartElement("Envelope", WsWellKnownUri.SoapNamespaceUri);

            if(ctx.Version.IncludeSoapHeaders)
            {
                hdr.ParseHeader(reader, ctx.Version);
            }
            
            msg.Header = hdr;

            reader.ReadStartElement("Body", WsWellKnownUri.SoapNamespaceUri);


//.........这里部分代码省略.........
开发者ID:awakegod,项目名称:NETMF-LPC,代码行数:101,代码来源:TextMessageEncodingBindingElement.cs


注:本文中的Ws.Services.WsaAddressing.WsWsaHeader.ParseHeader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。