Wednesday, January 02, 2008

XSDObjectGen - nested schema (imports) error with XSD.exe tool

If you read my previous post you may be good if you are using a simple XSD file (no nesting). But if i have multiple XSD files and they are all nested then there is a problem! Using XSD.exe tool doesn't help and fails for nested schema files.

It seems XSD.exe doesn’t seem to recognize element when generating code file...and it spits out the error ... "Class generation failed, cannot recognize root element". If you are facing the same error remove imports element from the XSD just include the namespace and try specifying multiple XSD file names from the command line while executing xsd.exe tool.

OR ... sweet way would be to look at XSDObjectGen tool. This is pretty exhaustive and can handle imports/mutiple xsd files easily. (though one level down). This code can then be used as a class exposed by web services.
Download Sample Code generator from here -

Saves lot of time and pain for sure! HTH, Thanks - Dipesh

No comments: