Copy message parts from message to message in BizTalk - biztalk

The only way I could find is to write a custom .NET assembly to perform the task.
Is there a way to do it within expression in orchestration? I have an input message that has parts and I'd like to copy those to the destination (mapped) message.
Thank you.

It basically depends what those parts are, but assuming we're talking about parts that aren't explicitly presented in a multi-part message type, and/or you don't want to use a map for each one, then yeah, the only way is through a helper component.

Related

BizTalk core format: redundant but all according to standard or "keep it simply stupid"?

I'm quite new in BizTalk mapping and my question now is:
Let's say that I need to receive UBL document, convert it to my Biztalk Core and send out same UBL. Of course I can perform 1:1 UBL->UBL without core format but I may need this core if I need to send out something else - EDIFACT, OIOXML, whatever else, so I believe it's a good practice to use core. So it looks like UBL -> Incoming map -> Core -> Outgoing map -> UBL.
So the question is: what is the best practice to create core format schema?
My incoming file must meet all OIOUBL standards so I have to use something pre-defined as XSD schema (e. g. like this: http://www.oioubl.info/Classes/en/Order.html). The same for outgoing file.
But on the other hand I know for the fact that in my case this standard contains a lot of redundant fields. I will never use some of these fields or parameters; some other are constants and there's no need to store it - we can just define default values in outgoing map...and so on.
So my question is: what is the best practice to build core file? Is it better to use full UBL xsd which meets all standards, even if it's redundant (in this case it will simplify incoming and outgoing maps - I can just use 1:1 mass copy) or it's better to KISS and to simplify core as it's possible using only fields that I really need and adding something one by one if I need anything else?
This question is not about code - just about what is the best practice.
Thanks. I would appreciate any advice.
Best practice would be for the internal core or canonical schema usually to match the inbound external schema (apart from target namespace) so you don't lose any data from the first mapping, as quite often when you find you do need to send it to another system and need another outbound mapping the fields you require might include on that you didn't for the original system. Of course to any rule there is an exception, and it is a matter of judgement as to when it isn't appropriate to do this.

Pact matching non JSON body

Is there any way of matching non JSON bodies (either XML, byte or whatever). Looking for the Python solution, however will appreciate any ideas behind that (even monkeypatching).
It's possible, but not directly supported.
Currently there's only the ability to match JSON. You can fake non-JSON matching by expecting a string body, but then you won't be able to use pact's built in matchers- which might mean your tests will be data dependent unless you do a bit of leg work.
There is a stub for xml support, but it's not currently implemented.
If you're willing to get your hands dirty in Ruby (not that different to Python!) you can write your own matcher. I can show you how to configure the pact-provider-verifier to use the custom matching code. Currently, if you use a content type that is not JSON, as J_A_X says, it will do an exact string diff.

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.

Execute code in assembly and access its objects

i have a difficult question:
I want to write some code into a textbox and compile it at runtime, like "Application.GetSystem().ObjectList.Count" so that i can get the result and display it in another textbox.
Would this be possible? It should be flexible, but you must access the same assembly-instance.
I know, CodeDOM gives you the possibility to compile assemblys at runtime, but if i used that one, it wouldn´t be the same instance and i don´t get the right result.
So, what would be a way to do this? CodeDOM looks like the right way. Reflection enables the access, but only if i use the same assembly... Or may i invoke the method of the generated assembly but in my programs assembly?
It´s more a theoretical question. I don´t know if i try it out, but would be nice to know :)
Yes, this is possible using reflection.

BizTalk messages overwriting each other?

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.

Resources