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


C# Message.CreateBufferedCopy方法代码示例

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


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

示例1: SecureMessageDecryptor

		protected SecureMessageDecryptor (
			Message source, MessageSecurityBindingSupport security)
		{
			source_message = source;
			this.security = security;

			// FIXME: use proper max buffer
			buf = source.CreateBufferedCopy (int.MaxValue);
Console.WriteLine ("####### " + buf.CreateMessage ());

			doc = new XmlDocument ();
			doc.PreserveWhitespace = true;

			nsmgr = new XmlNamespaceManager (doc.NameTable);
			nsmgr.AddNamespace ("s", "http://www.w3.org/2003/05/soap-envelope");
			nsmgr.AddNamespace ("c", Constants.WsscNamespace);
			nsmgr.AddNamespace ("o", Constants.WssNamespace);
			nsmgr.AddNamespace ("e", EncryptedXml.XmlEncNamespaceUrl);
			nsmgr.AddNamespace ("u", Constants.WsuNamespace);
			nsmgr.AddNamespace ("dsig", SignedXml.XmlDsigNamespaceUrl);

		}
开发者ID:kumpera,项目名称:mono,代码行数:22,代码来源:SecureMessageDecryptor.cs

示例2: OnGetToken

		Message OnGetToken (Message input)
		{
			MessageBuffer buf = input.CreateBufferedCopy (10000);
			VerifyInput2 (buf);

			// FIXME: create response message (when I understand what I should return.)
//			throw new MyException ();
//*
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml ("<Response>RESPONSE</Response>");
			X509Certificate2 cert = new X509Certificate2 ("Test/Resources/test.pfx", "mono");
			SignedXml sxml = new SignedXml (doc);
			MemoryStream ms = new MemoryStream (new byte [] {1, 2, 3});
			sxml.AddReference (new Reference (ms));
			sxml.SigningKey = cert.PrivateKey;
			sxml.ComputeSignature ();

			Message msg = Message.CreateMessage (input.Version, "http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue", sxml.GetXml ());
			msg.Headers.Add (MessageHeader.CreateHeader (
				"Security", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", null, true));

			return msg;
//*/
		}
开发者ID:whereisaaron,项目名称:mono,代码行数:24,代码来源:IssuedSecurityTokenProviderTest.cs

示例3: TransformAndHandleFault

        private Message TransformAndHandleFault(Message message)
        {
            if (message.Headers.Action.EndsWith("/fault"))
            {
                var buffer = message.CreateBufferedCopy(int.MaxValue);

                var clonedMessage = buffer.CreateMessage();

                var reader = clonedMessage.GetReaderAtBodyContents();

                reader.Read();
                reader.Read();
                reader.Read();
                reader.Read();
                reader.Read();

                var val = reader.Value;

                if (string.IsNullOrWhiteSpace(val))
                {
                    return buffer.CreateMessage();
                }
                
                if (val == Constants.SerializationFaultCode.ToString(CultureInfo.InvariantCulture))
                {
                    var store = ObjectBuilder.GetModelStore();

                    store.RemoveAll();
                }

                return buffer.CreateMessage();
            }

            return message;
        }
开发者ID:yonglehou,项目名称:ProtoBuf.Wcf,代码行数:35,代码来源:ProtoBufMetaDataRequestChannel.cs

示例4: OnGetTokenWrongResponse

		Message OnGetTokenWrongResponse (Message input)
		{
			VerifyInput (input.CreateBufferedCopy (10000));

			throw new MyException ();
		}
开发者ID:whereisaaron,项目名称:mono,代码行数:6,代码来源:IssuedSecurityTokenProviderTest.cs

示例5: BeforeSendReply

        public void BeforeSendReply(ref Message reply, object correlationState)
        {
            if (correlationState != null)
            {
                MessageInfo messageInfo = correlationState as MessageInfo;
                if (messageInfo != null)
                {
                    messageInfo.ServerEndTimeStamp = DateTime.Now;

                    MessageBuffer mb = reply.CreateBufferedCopy(int.MaxValue);
                    Message responseMsg = mb.CreateMessage();
                    reply = mb.CreateMessage();

                    XmlDictionaryReader bodyReader = responseMsg.GetReaderAtBodyContents();
                    if (bodyReader.IsStartElement("Binary"))
                    {
                        bodyReader.ReadStartElement("Binary");
                        byte[] bodyBytes = bodyReader.ReadContentAsBase64();
                        messageInfo.Response = Encoding.UTF8.GetString(bodyBytes);
                    }
                    else
                    {
                        messageInfo.Response = bodyReader.ReadOuterXml();
                    }

                    if (reply.IsFault)
                    {
                        messageInfo.IsError = true;
                    }

                    if (messageInfo.Response.Contains("<Binary>"))
                    {

                    }

                    string message = String.Format("Response => {0} {1}", messageInfo.ServerEndTimeStamp.ToString(CultureInfo.InvariantCulture), messageInfo.Response);
                    if (IsDisplayConsole)
                    {
                        Console.WriteLine(message);
                    }

                    if (IsLogFile)
                    {
                        _logger.Log(LogLevel.Info, message);
                    }
                }

                if (OnMessage != null)
                {
                    OnMessage(this, new MessageInspectorArgs
                    {
                        MessageInspectionType = MessageInspectionType.Response,
                        Message = messageInfo
                    });
                }
            }
        }
开发者ID:ZyshchykMaksim,项目名称:WCF.REST,代码行数:57,代码来源:MessageInspectorBehavior.cs


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