Dotnet datatype raises error reading utf-16 from mess.queue

greys
Member Posts: 29
Hi,
I'm currently upgrading legacy code to benefit from the latest dotnet techniques. I've used Rashed Amini's example (http://mibuso.com/blogs/ara3n/2011/04/02/integrating-with-msms-using-dotnet-data-types-in-nav-2009-r2/) to make a connector that can read message queues with dotnet datatypes:
Datatypes:
Q DotNet System.Messaging.MessageQueue.'System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
QMsg DotNet System.Messaging.Message.'System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MyVariant Variant
When the message body is of utf-8 nature, all goes well and the xml from the body can be extracted perfectly using an xmlport in the function FurtherProcessingOfThisMessage(XmlDomDotNet). However, when the body is utf-16, the code MyVariant := QMsg.Body raises the error 'A call to System.Messaging.Body failed with the message: Cannot deserialize the message passed as an argument. Cannot recognize the serialization format'.
Since the queue is feeded from a third party program that can only send in utf-16, I'm facing a problem here. Anyone with a solution? Is there a way to format the body to utf-8 before it's assigned to the variant?
Best regards
Josh
I'm currently upgrading legacy code to benefit from the latest dotnet techniques. I've used Rashed Amini's example (http://mibuso.com/blogs/ara3n/2011/04/02/integrating-with-msms-using-dotnet-data-types-in-nav-2009-r2/) to make a connector that can read message queues with dotnet datatypes:
Datatypes:
Q DotNet System.Messaging.MessageQueue.'System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
QMsg DotNet System.Messaging.Message.'System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
MyVariant Variant
Q := Q.MessageQueue(PathToQueue); Q.Formatter := QActiveXFormatter.ActiveXMessageFormatter; IF TryPeek THEN BEGIN QMsg := Q.Peek(TS.TimeSpan(0,0,1)); END ELSE BEGIN CLEAR(ReceiveMSMQ); ReceiveMSMQ.SetTryPeek; IF ReceiveMSMQ.RUN THEN REPEAT QMsg := Q.Receive(TS.TimeSpan(0,0,10)); CLEAR(MyVariant); MyVariant := QMsg.Body; CLEAR(XmlDomDotNet); XmlDomDotNet := XmlDomDotNet.XmlDocument; XmlDomDotNet.LoadXml(FORMAT(MyVariant)); i += 1; FurtherProcessingOfThisMessage(XmlDomDotNet); COMMIT; CLEAR(XmlDomDotNet); CLEAR(ReceiveMSMQ); ReceiveMSMQ.SetTryPeek; UNTIL (NOT ReceiveMSMQ.RUN) OR (i = 25); END; CLEAR(QMsg); CLEAR(Q); CLEAR(XmlDomDotNet);
When the message body is of utf-8 nature, all goes well and the xml from the body can be extracted perfectly using an xmlport in the function FurtherProcessingOfThisMessage(XmlDomDotNet). However, when the body is utf-16, the code MyVariant := QMsg.Body raises the error 'A call to System.Messaging.Body failed with the message: Cannot deserialize the message passed as an argument. Cannot recognize the serialization format'.
Since the queue is feeded from a third party program that can only send in utf-16, I'm facing a problem here. Anyone with a solution? Is there a way to format the body to utf-8 before it's assigned to the variant?
Best regards
Josh
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions