BizTalk Orchestration Error: Root element is missing
November 11, 2015
Error: Root Element is Missing
Shape name: msgABCDetail
Exception thrown from: segment 4, progress 22
Inner exception: Root element is missing.
This error occurs in an orchestration, typically after you have run a map, and the map doesn’t create any output.
The map is in a construct statement, and presumably the message created in the construct statement should not be empty.
The way to test or fix this is as follows:
1) Obtain a copy of a the message that goes into the map (might have to add debug or write message to disk or trace), and save to disk.
2) Test that message in Visual Studio using the right click “Test Map” option on the map (first set the “TestMap Input Instance” property to the filename you saved from the step above.
3) Typically the issue is a namespace or higher level node is missing. This causes none of the xpaths in the XSLT to match, and thus nothing is generating on the “right side” of the map. When you test the map, the Output window will show something like this: “The output is stored in the following file: xxx.xml”. If you cntl-click on that file, that file will open. In all likelihood it will be empty (blank). [If it has data in it, there is a chance the code you are running doesn’t match the current version of the source code/map you are testing, indicating you might need to redeploy.]
4) To check further, you can also check the file against the schema, to make sure it is valid. This may help indicate an element name or namespace that is wrong that could cause the map to result in empty output. Set the schema property “Input Instance Filename”, then right click on the schema and select “Validate Instance”. If it fails, you might try generating an instance, then use a file compare or your own eyeballs to compare the generated instance to the instance you were validating (experience teaches you what to look for).
Here’s a specific case I dealt with today. My data file had a root element named eisresultset. It was built by xpathing to a node of the data data returned to us by a vendor. Due to the way the vendor packs the data in a generic XmlDoc packet, the WSDL did not build the schemas for us, and I had to do it manually. When I built the schema for esiresultset, I misspelled the root element name and had esiresultset. The reversal of those two letters make a huge difference!
When I validated the data instance against the schema, the output window told me clearly:
e:\MyDir\MySubDir\map_EsiResultSet_To_DBTableMotoDetails_TestIn1.xml: error BEC2004: The ‘eisresultset’ element is not declared.
The second mistake I made, was in my map, I had mapped eisrecord, a separate schema with that repeats inside of eisresultset. So mapping a schema that starts with a higher level element than what I mapped would never result in a good map output.