0

我有一个奇怪的情况,它只出现在我正在处理的这个编排中。

我收到一条接收消息。我使用表达式形状并将其写入变量“xmlDoc”,以便验证其中的内容。然后我有一个消息分配形状,其中我将一串 XML 加载到变量“xmlDoc2”并将该变量分配给第二条消息并将其写出来以便我可以验证它。然后我有另一个表达式形状并尝试再次写出第一条消息,它显然已被第二条消息信息替换。

它不是平行形状,消息分配仅构建第二条消息。在接收和我看到这个问题的地方之间,我正在做一些决定形状并从接收消息构建其他消息。它们都可以正常工作并且不会覆盖任何内容(执行与我稍后尝试执行的相同的过程。)

有人以前看过这个或看到我遗漏的东西吗?

ETA:这个过程有点像这样:

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
4

1 回答 1

0

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.

于 2011-01-06T16:21:12.057 回答