BizTalk messages overwriting each other? - biztalk

I have an odd situation that has only come up in this one orchestration I'm working on.
I have a Receive message come in. I use an Expression shape and write it to a variable "xmlDoc" so I can verify what is in it. I then have a Message Assignment shape where I Load a string of XML to a variable "xmlDoc2" and assign that variable to a second message and write it out so I can verify it. I then have another Expression shape and attempt to write out the first message again and it's apparently been replaced with the second message information.
It's not in a Parallel shape, and the Message Assignment is only building the second message. Between the receive and where I'm seeing this issue, I'm doing a few Decide shapes and building other messages from the Receive message. They all work fine and don't overwrite anything (do the same processes as what I'm trying to do later.)
Anyone seen this before or see something I'm missing?
ETA: The process works a bit like this:
Send Message comes in
xmlDoc = Send Message
xmlDoc.OuterXml is written to a table
xmlDoc2 = "<root><xml></xml></root>"
Second Message = xmlDoc2
xmlDoc2.OuterXml is written to a table
xmlDoc = Send Message <-- What should happen
xmlDoc = Second Message <-- What is happening

I could not reproduce your exact problem but I got close. I think there are some implied statements in your process outline that would be critical for us to understand what's really happening. In any case, I think your BizTalk messages do not get overwritten, but that the XmlDocument variables are.
I think you may have been hit by one of the fundamental confusions a developer coming from a Java or VB6 background encounters when working with C#.
C# is a Managed Language
Please, remember that C# is a managed language, in that it uses a garbage collector to reclaim unused references to objects. The key word here is Reference.
When you write the following lines:
xmlDoc2 = "<root><xml/></root>";
SecondMessage = xmlDoc2;
Basically, you have two references to the same content. Namely, two references xmlDoc2 and SecondMessage which refer to the assigned string.
So, depending upon the code you use to "write out" the XML content of your BizTalk messages, you may be overwriting some references.
Furthermore, if this happens in the context of a Construct shape, you may be inadvertently overwriting the content of the BizTalk message itself.
A Solution?
This problem does not usually manifest itself when working with BizTalk. I personally never encountered this issue.
If you update your original question with the exact code for both Expression shapes and the Assignment shape, I'll update this response with more appropriate guidance.

Related

Trying to read multiple lines from txt file separated with :, but I'm getting imbRecoverableException caught from worker -> parseNext

As I'm new to IBM MQ and IIB I'm trying to experiment around with online tutorials. At the moment I'm trying to make a simple app that reads several lines in txt file separated by colon and writes them into XML file. Currently I'm stuck at reading multiple lines from file. I know how to make it work with only one line, but can't with more than one. I do know that there should be a parent-child relationship between two complex types but can't configure them properly. Also im using RFHUtil to send message file into queue.
Since I can't find much googling it, I hope someone with right knowledge could help around.
Don't have any code, but got my message definition picture: http://prnt.sc/nv9npr
Here is the error I'm getting: http://prnt.sc/nv9nyi
So two things I can see in your current screen shots.
In the first screenshot I can see \r\n i.e. CRLF which indicates that your separator needs to either be CRLF or your model needs to deal with the CRLF.
In the second you've got a partially parsed message. Try setting the Advanced Parser options on your Input node to ParseComplete things will still blow up but you should get some better diagnostic information in the ExceptionList.
Looks like you are trying use the MRM parser which has been replaced by the DFDL parser. I suggest you find some tutorials on the DFDL parser, it's much more efficient. Also there is support built into the Toolkit which will let you debug the Message Model you create Testing a DFDL schema by parsing test input data

srReader.GetValue(1) using vb.net

I am very New to Vb.net.
We are using fortify software for projects when it is going to LIVE. In that process I got some cross-Site Scripting : persistent Data flow issues.
Can anybody know how to resolve the following issue:
CType(srReader.GetValue(1), String)
CType(srReader.GetValue(2), String)
When I am loading the above value into some labels it is showing error; error name as mentioned above.
guys can anybody knows how to get this value in a different way.
Can you give more context around where you are using this type cast? I don't know what fortify software is, but if it is a security analysis tool and you are receiving "Cross site scripting" errors, then the problem is most likely that you are returning this string in it's native state to be rendered as HTML. To avoid cross-site scripting risks, you should be html-encoding this value. That is, unless it is known to be safe and intended to be rendered as HTMl, in which case you'll just have to ignore or suppress this error.

Which functoid(s) allow use of a DataTable, returned from an external assembly, in a BizTalk map?

I figured I'd be able to use an Index functoid but it doesn't seem to like my first parameter (the scripting functoid that calls the external assembly) - a red X in place of the usual green check mark.
The thing that makes me think it's possible, is that the Index functoid doesn't give me an error at all - it compiles and deploys with no complaints. The problem is that the mapping never takes place, I get a catastrophic failure (IMO) because it doesn't even return an error.
So, any way to use an external assembly that returns a DataTabe/DataRow/DataSet in a BizTalk map?
I know this does not address your question entirely but I always think that any calls to external dependencies should be done before the mapping stage, and the results stored in a message.
The map would have multiple input schemas, one of which could be a DataRow (modelled on the ADO DataRow).
Then when you call the transform you pass all the messages in which are needed to do the transform. This makes it much easier to isolate your genuine mapping failures from other failures.
This might help:
Code Behind BizTalk Functoids
You may be able to get some insight into how the mapper does its thing.

Asp.net error object not set to a reference

Because I rush in development (a lot of whip cracking here) and declare my objects at the top of the function and instantiate inside my try-catch block, I get a lot of the good old "object not set to an instance of an object" errors while doing TDD, and later if I do miss a branch that object was used in (doing VB now, would prefer C#) or just in every day coding, object not set to an instance of an object is a bit vague. Sure the stack trace sends me to the line the error occured at, but it would be nice if I could modify my logging to either name the object or its type because sometimes I have multiple objects on the same line. It's not the end of the world, but in the end it would save me a few minutes each day. Any ideas on how I can pass the info on which object wasn't set? Thanks
It is non trivial to "modify your logging" to output variable name or type - I am sure that if the framework could easily get this information from the executing IL, MS would have included it the null reference exception.
Prevention is always better than cure. Here are a couple of tips I would do
Fix your compiler warnings
C# would generate a compile error if it detects that there are code paths that could use an unassigned local variable. [For some odd reason] VB.Net will still compile but the compiler will generate a warning - take heed of these and go and fix the code and you should never run into the problem of unassigned variables again!
Adopt a different coding pattern for variable declaration
I appreciate that method variable scope in ye olde VB was that the variable was visible throughout the entire method regardless of where it was defined. As a result, it was a reasonable practice to put all your var declarations at the top of the method. VB.Net of course is different - you can only use variables after they are declared and so it is OK (and I would say preferable*) to put the declaration (and assignment) closer to where the variable is actually used. This should help you see "by eye" if your program logic means it is possible to use an unassigned variable.
Some people think this is a think that it is always good practice to put variable declarations in a block at the top of the method. I will not argue against them but I would say that that approach works best with small methods that do not use lots of variables.

Why does this code only work when I use a break point?

See code below, for some reason it only works when I put a breakpoint on line 2 (*) is there some delay? Is it starting the next line before it finishes the 2nd one?
dp.SSLCertStoreType = nsoftware.IBizPayPal.DirectpaymentSSLCertStoreTypes.sstPEMKey
*dp.SSLCertStore = My.Computer.FileSystem.ReadAllText(Server.MapPath("\cert_key_pem.txt"))
dp.SSLCertSubject = "*"
Note: The error is thrown on the 3rd line only when the breakpoint is set on the 2nd line, after releasing the break the program executes my paypal purchase via credit card.
I will post the error again I am replicating it now...
System error: Could not acquire security credentials: error 8009030E.
There it is, while it should say "Order Confirmed!" type message if working correctly.
Almost certainly a threading issue, but nobody is going to be able to answer definitively unless they're familiar with nsoftware.IBizPayPal
Sometimes you can find that breaking can mutate an object's state, due to the locals window evaluating object properties. If they have a side-effect, then all bets are off, unfortunately :( No idea whether this is happening in your case.
I have no knowledge of ASP, so just wondering aloud: Could this be due to multithreading? You know when you put a break point you sort of freeze execution of all threads, but not so in the real execution.

Resources