當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。