views:

112

answers:

1

I have created the simplest web service in c#:

public void AddData(DataSet ds)

The generated schema (Wsdl) looks like this:

<s:schema xmlns:s="http://www.w3.org/2001/XMLSchema"&gt;
...
<s:element ref="s:schema" />
...
</s:schema>

Note the schema does not contain any import/include elements.

I am trying to load this schema to a c# System.Xml.XmlSchema and add it to System.Xml.XmlSchemaSet:

var set = new XmlSchemaSet();
var fs = new FileStream(@"c:\temp\schema.xsd", FileMode.Open);
var s = XmlSchema.Read(fs, null);
set.Add(s);            
set.Compile();

The last line throws this exception:

The 'http://www.w3.org/2001/XMLSchema:schema' element is not declared.

It kind of makes sense: The schema generated by .Net uses the "s:schema" type which is declared in a schema which is not imported.

  1. Why does .Net create a non valid schema?
  2. How to compile the schema anyway? Whay I did is download the schema in http://www.w3.org/2001/XMLSchema and added it to the XmlSchemaSet also. This did not work since that online schema contains DTD definition. I had to manually remove it and now all works. Does this make sense or am I missing something?
A: 

Hi,

How did you manage to get it work? You removed <s:element ref="s:schema" />?

Haripraghash