简体   繁体   English

使用WCF从MSMQ队列接收任何XML消息?

[英]Use WCF to receive any XML message from an MSMQ Queue?

I have an MSMQ that receives XML format messages from various sources. 我有一个MSMQ,它接收来自各种来源的XML格式消息。 I have a WCF endpoint (using MsmqIntegrationBinding) that I want to receive these messages. 我有一个WCF端点(使用MsmqIntegrationBinding),我想接收这些消息。 I defined the following: 我定义了以下内容:

[ServiceContract(Namespace = "http://TestApp.MSMQService", ProtectionLevel = ProtectionLevel.None)]
[ServiceKnownType(typeof(String))]
public interface IMsmqReceiverService
{
    [OperationContract(IsOneWay = true, Action = "*")]
    void SubmitQueueMessage(MsmqMessage<String> msg);
}

Hoping that would receive any XML message, however it only receives messages formated: 希望能收到任何XML消息,但它只接收格式化的消息:

<?xml version="1.0">
<string>message</string>

For various reasons we don't know, and don't want to know, the schema of the xml message, getting it into a String would be sufficient. 由于各种原因,我们不知道,也不想知道,xml消息的模式,将其变为String就足够了。 How can I define an endpoint that recieves XML messages with any nodes that arrive on the queue regardless of the schema used in the message? 如何定义一个端点,它接收到任何到达队列的节点的XML消息,而不管消息中使用的模式如何?

Additionally, given a String buffer containing the XML of a message, how can I put that onto a MSMQ using System.Messaging.MessageQueue.Send without it getting wrapped in additional xml? 另外,给定一个包含消息XML的String缓冲区,如何使用System.Messaging.MessageQueue.Send将其放入MSMQ而不用其他xml包装?

I haven't used the MSMQ integration, but try MsmqMessage<XmlElement> . 我没有使用MSMQ集成,但尝试MsmqMessage<XmlElement>

Don't manipulate XML as a string if you can possibly help it. 如果您可以帮助它,请不要将XML作为字符串进行操作。 Always use one of the many XML APIs. 始终使用众多XML API中的一个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM