- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我想从 C# WPF 应用程序的消息队列中读取 XML 消息。消息由 Navision 代码单元保存到队列中。首先,我不太确定保存在队列中的消息是否可用,因为它们采用某种十六进制格式,如下所示:
FF FE 3C 00 3F 00 78 00 ÿþ<.?.x.
6D 00 6C 00 20 00 76 00 m.l. .v.
65 00 72 00 73 00 69 00 e.r.s.i.
6F 00 6E 00 3D 00 22 00 o.n.=.".
31 00 2E 00 30 00 22 00 1...0.".
20 00 65 00 6E 00 63 00 .e.n.c.
6F 00 64 00 69 00 6E 00 o.d.i.n.
67 00 3D 00 22 00 55 00 g.=.".U.
54 00 46 00 2D 00 31 00 T.F.-.1.
36 00 22 00 20 00 73 00 6.". .s.
74 00 61 00 6E 00 64 00 t.a.n.d.
61 00 6C 00 6F 00 6E 00 a.l.o.n.
...
从队列中接收消息已经有效,但不知何故格式错误,因为我收到此运行时异常“无效操作异常:无法反序列化作为参数传递的消息。无法识别序列化格式。”
我正在使用这段代码来阅读消息:
public MainWindow()
{
InitializeComponent();
mqCustomerData = new MessageQueue(@".\private$\customerData");
mqCustomerData.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
mqCustomerData.ReceiveCompleted += new ReceiveCompletedEventHandler(mqCustomerData_ReceiveCompleted);
mqCustomerData.BeginReceive(new System.TimeSpan(0, 0, 0, 30));
}
private void mqCustomerData_ReceiveCompleted(object sender, System.Messaging.ReceiveCompletedEventArgs e)
{
Message m = new Message();
m.Formatter = new XmlMessageFormatter(new Type[] { typeof(String) });
m = mqCustomerData.EndReceive(e.AsyncResult);
string text = (string)m.Body;
}
我搜索了这个问题,但没有找到有用的解决方案,只找到了遇到同样问题的其他用户的帖子,如下所示:http://www.webmasterworld.com/microsoft_asp_net/4119362.htm
我希望你们当中有人能帮我解决这个问题:)
最佳答案
在 competent_tech 的回答中,没有重载
Encoding.Unicode.GetString(m.Body);
接受一个字符串参数。
如果这是您想要使用的方法,您需要将字符串转换为字节数组 -
byte[] arr;
using(MemoryStream ms = new MemoryStream())
{
m.BodyStream.Position = 0;
m.BodyStream.CopyTo(ms);
arr = ms.ToArray();
}
string s = Encoding.Unicode.GetString(arr, 0, arr.Length);
关于c# - 从 msmq 读取时的 XML 反序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8261971/
我刚刚和一位 Microsoft MVP 聊天,他告诉我 MSMQ 已经过时了。这是真的?那么 SOA 的基础设施是什么??? 最佳答案 好吧,他们发布了一个带有 Vista 的新版本 (4.0),它
只是想确认如何将消息发送到远程事务性消息队列。 假设我有两台机器,A 和 B。 机器 A 有一个用于接收消息的事务队列。 Windows 服务监视此队列并对数据执行某些操作(将其保存到 SQL Ser
我一直看到documentation表示不可能发送到事务范围之外的远程事务 msmq 队列。我发现这很难相信,因为我认为我已经这样做了好几个星期了。我有一个小应用程序,它将消息发布到事务性的远程队列。
我正在使用 MSMQ 传输一个 byte 数组。 格式化程序是一个 BinaryMessageFormatter。 目标队列是私有(private)队列,我正在使用直接 TCP 通信。 目标机器在不同
有人可以为我指出一些关于为队列集群设置 MSMQ 的好资源吗?我有兴趣帮助: 实际设置集群MSMQ节点,并使其运行 设置应用程序以将消息发送到集群队列。 设置应用程序(至少 2 个)以从同一个集群队列
我是消息传递的新手,有点不清楚 MSMQ 是否可以为事务队列传递乱序消息。我想这一定是因为如果一条消息没有得到正确处理(并且因为我们将使用多个“竞争消费者”),那么其他消费者可以继续处理消息,同时将失
我们使用 BizTalk Server 通过 MSMQ 发送消息。接收系统要求每条消息都将扩展属性设置为 guid(作为字节数组)。 MSDN 记录了 MSMQMessage here 的 Exten
我正在做 NServiceBus 网站 ( http://docs.particular.net/samples/step-by-step/ ) 上的示例,当我在 Visual Studio 中运行时
我们有一个基于 NServiceBus 的 Pub/Sub 系统,我们有间歇性问题,消息无限期地卡在发布者传出队列上,而不是被传输到订阅者输入队列。 注意事项: 当我们重新启动发布者服务和订阅者服务时
当您向远程队列发送消息时,会在您自己的机器上创建一个临时传出队列。这是否意味着如果您自己的机器上没有安装MSMQ,您就不能使用远程队列? 最佳答案 你是对的。如果你自己的机器上没有安装 MSMQ,你就
我正在尝试使用以下路径连接到远程私有(private) MSMQ 队列: "FormatName:DIRECT=OS:remoteMachineName\Private$\MyQueue" 我收到以下
据我从文档中看到,您应该检查消息队列中是否有消息的方法是使用 Peek 方法。然后,您依靠它失败并返回 MessageQueueException 来告诉您队列为空。 public bool
我正在尝试使用主机文件中的别名指向包含 MSMQ 的服务器。如果我在 MSMQ 路径中指定实际服务器名称,则一切正常: var queue = new MessageQueue("FormatName
是否可以直接从队列中以字符串形式读取消息(与您在计算机管理 MSC 管理单元中查看 MSMQ 消息时看到的消息正文相同),以便我可以自己将其保存到数据库中?我希望能够存储它以便稍后重播而不会丢失任何数
有没有办法清除传出队列。似乎我无法使用 MMC 管理单元完成此操作,当我尝试在代码中清除它时出现错误 Format name is invalid将消息发送到的计算机不存在,因此它们永远不会被发送,但
有一个名为 queue1 的公共(public)队列在机器 A 上。我想从机器 B 向这个队列发送消息。为了实现这一点,我编写了那个 c# 代码。 if (MessageQueue.Exists("m
是否有某种标准配置设置、服务或工具可以接受来自一个队列的消息并将其移至另一个队列?自动处理死消息问题,并提供一些重试能力?我想这就是“MSMQ 消息路由”所做的事情,但似乎找不到有关它的文档(Wind
我正在尝试创建一个 MSMQ 解决方案,对于某些消息,我希望它们仅在下午 6 点之后处理,那么 MSMQ 中是否有一种方法可以在 Future 中处理该消息? 最佳答案 队列是一种先进先出的数据结构。
我们的系统中有许多 MSMQ 队列,包括私有(private)队列和公共(public)队列。有时,从队列中读取的 Windows 服务会崩溃,因此消息会在该队列中堆积。一旦队列达到一定大小(可能是
我们在使用 NServiceBus 的负载平衡的高容量环境中遇到了 MSMQ 问题。 我们的环境如下所示: 1 F5 通过循环分配网络流量到 6 个应用服务器。这 6 个服务器中的每一个都使用一个 B
我是一名优秀的程序员,十分优秀!