XDocument로 주문한 것이있어서 메시지의 본문에 붙여서 MSMQ 대기열로 보내기 만하면됩니다. 나는 이미 주문 객체를 효과적으로 직렬화했으며 지금은 그냥 보내고 싶다. 이것이 가능한가?MSMQ를 통해 XDocument를 보내는 방법 (WCF 사용)?
여기 WCF를 사용하고 있지만 일반적인 오래된 msmq 솔루션에 만족합니다. XDocument를 직렬화 할 수 없다는 오류가 발생합니다. 분명히 그렇게 할 수는 없지만 XDocument를 메시지 본문에 어떻게 가져 옵니까? 내 자신의 시리얼 화자를 굴려야합니까?
public void SendOrder(XDocument order)
{
var address = new EndpointAddress(@"msmq.formatname:DIRECT=OS:myServer\private$\myQueue");
var binding = new MsmqIntegrationBinding();
binding.Security.Mode = MsmqIntegrationSecurityMode.None;
binding.ExactlyOnce = false;
binding.Durable = false;
var channelFactory = new ChannelFactory<IOrderSubmitter>(binding, address);
var channel = channelFactory.CreateChannel();
var message = new MsmqMessage<XDocument>(order);
message.Label = "Really Big Order with lots of profit";
message.BodyType = (int)System.Runtime.InteropServices.VarEnum.VT_ARRAY;
using (var scope = new TransactionScope(TransactionScopeOption.Required))
{
channel.SubmitOrder(message);
scope.Complete();
}
}
[ServiceContractAttribute(Namespace = "http://my.namespace.com", Name = "Hello")]
public interface IOrderSubmitter
{
[OperationContract(IsOneWay = true)]
void SubmitOrder(MsmqMessage<XDocument> message);
}
여기에 질문을 게시하기 전에 시도했지만, 모든 내용이 태그로 묶여 있습니다. XDoc에있는 그대로 XML이 필요합니다 ... –
autonomatt