本文整理汇总了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);
}
示例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;
//*/
}
示例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;
}
示例4: OnGetTokenWrongResponse
Message OnGetTokenWrongResponse (Message input)
{
VerifyInput (input.CreateBufferedCopy (10000));
throw new MyException ();
}
示例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
});
}
}
}