Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Decrypting Message from MSMQ
- This topic has 7 replies, 1 voice, and was last updated 9 years, 3 months ago by
community-content.
-
AuthorPosts
-
-
December 12, 2006 at 4:03 AM #16848
Hi All!
I am having problems in implementing decryption using a custom pipeline component, which uses DES algorithm. When it picks the message from a File, it works fine but when it picks up the same data from MSMQ, it gives Bad Data error.
I put the following code in the Execute method and found out that, it is not been able to Get the size of the queue message, while it does for the File one.
ulong DataSize = 0;
bool Implemented = false;
inmsg.BodyPart.GetSize(out DataSize, out Implemented);
DataSize and Implemented remain 0 and false for queue message,Whereas there is a valid DataSize like 336 and true for Implemented for File message.
I am using exactly the same stream to write data to both file and queue. I use MessageToSend.BodyStream to assign the stream to write to queue. Although it doesn’t pick the size of the queue message through, GetSize method, but it is receiving the same data, I confirmed that by writing the data to EventLog and it is the same for both.
Does anyone out there has any idea why this might be happening?, why it is not treating the data from File and Queue the same way?.
Also if anyone out there has implemented a Decryption/Encryption pipeline component for Biztalk, which works with MSMQ, then please redirect me to there…
Any help,
Very appreciated.
Regards,
Sajid.
-
December 12, 2006 at 9:18 AM #16850
Hello Sajid,
It seems like a formatting problem to me when the data is pulled from MSMQ by your decryptor. See Microsoft KB Article ID : 310683
I hope that will help.
Regards,
NNdM
-
December 12, 2006 at 10:49 AM #16852
Thanx NND for reply,
I am already writting the data to the queue as a Stream, the same stream that I use to write to the file, by setting the BodyStream of a MSMQ message. But I dont know How I can force a pipeline component to read the data from the queue (or receive location) by using my method?, rather then its own default.
Regards,
Sajid.
-
December 12, 2006 at 12:04 PM #16854
Hello Sajid,
Your decryptor need to specify the reading of a message by using a custom formatter. The sending and reading of MSMQ messages are defaulted to XMLMessageFormatter. Try to check the queue messages and see how they differ before and after you send, and before and after you read. Although only a portion of the message body can be seen, you should be able to see the differences.
Good Luck !
NNdM
-
December 13, 2006 at 3:06 AM #16870
I know that MSMQ uses XmlFormatter by default, and it appends, <string> at the start and end of the message. That's why I am using the BodyStream property of the message and not the Body. BodyStream, writes the stream as it is, and there are no problems there, Both the File and queue message data are the same when they reach the pipeline component, I've checked that by writting to Eventlog from there. But for that same Queue message it gives Bad Data when trying to decrypt it.
The difference I spotted as I mentioned in my first post, is when I try to Get Size, of the queue message by using BodyPart.GetSize(out Size, out Implemented), it gives Size=0, and Implemented = false for the queue message and Size=336, and Implemented=true for the file message. As I said both have the same stream, so why there is a change of behaviour there.
Now this is what Biztalk documentation say about the Implemented out paramter of GetSize method:
Pointer to a Boolean used to return the information if the message size can be determined. true if the IBaseMessage object can determine the size; otherwise, false.
Why it is unable to determine it is beyond me, Hope I've explained myself better now, Any ideas?
Regards,
Sajid.
-
-
-
-
December 13, 2006 at 9:16 AM #16881
I think the reason you get the error is because the MSMQ adapter might be giving you a non-seekable stream, which doesn't have a way to query the length of the stream. That's actually quite normal and fairly common when working with streams. Why do you need the length of the message to decrypt it?
(Mind you each adapter will return streams in messages with particular characteristics; that's something you'll encounter pretty often in BizTalk and it's something to keep in mind)
-
December 13, 2006 at 10:43 AM #16883
Tom,
I dont need the size of the message to decrypt it, Since I was not able to decrypt the same message got from the queue, that decrypted if from a file. I was troubleshooting in the Component and came across this, thought this might be the cause. If this is not the problem, then do you people see any other reason why an absolutely same queue message is not decrypted by the component while a file message is?
Regards,
Sajid.
-
December 13, 2006 at 3:44 PM #16888
It's hard without seeing some more code, sorry. Normally, I can't see a reason why it would cause any particular issues, unless you're missing something. For example, make sure you're flushing all streams on the sender side (it's worth checking, as some streams are more forgiving about this than others).
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.