As BizTalk consultants we get a nice surprise every now and then... I had my Surprise Last week.
Here is the situation :
In biztalk we receive a schema, let's say we receive schema 'Drivers', in drivers whe have a name element. The name element is just a string.
Now we map the schema 'Drivers' to the Schema 'F1Drivers'. In the schema 'F1Drivers' we have the element 'DriverName'. The element DriverName can be two values 'Michael Shumacher' and 'Rubens Barichello'.
Ok everything fine until now. We create a map that maps schema 'Drivers' to 'F1Drivers', we test the map and indeed if the field 'Name' in 'Drivers' contains 'Jos verstappen' the map wil fail and if the name is 'Michael Shumacher' the map will succeed.
Now we use the map in an Orchestration. You would expect the map to fail in the orchestration as well but it doesn't.
This was the point where I scratched some hears of my head... Why didn't it fail, the resulting xml document was invalid ?
Lucky for me I wasn't the only consultant with this problem. Thanks to e very helpfull collegue I got hold of a VERY usefull piece of code. The code was posted by the ArchHacker. (Cool XSD Validation Function for Orchestration)
For sure, to make it a really good piece of code I just had to convert it to VB.NET but it works like a charm.
(and I know there are more F1 drivers out there but I just couldn't think of a name........)