Type 'http://microsoft.com/wsdl/types/' is not declared
Hello.
I am trying to validate incoming requests to my web service by checking them
against the schema generated in the WSDL file (by Visual Studio 2005), but I
cannot even add the schema to an XMLSchemaCollection before an
XMLSchemaException is thrown:
System.Xml.Schema.XmlSchemaException: Type
'http://microsoft.com/wsdl/types/:guid' is not declared
If I use another type, e.g. "string", the schema is added without
objections. If I open the wsdl file in Visual Studio 2005 I get a wiggly line
stating the same error message for this row:
<s:element minOccurs="1" maxOccurs="1" name="RequestId" type="s3:guid" />
This is the code from where the exception is thrown (last row, "Add" method):
foreach (string wsdlFile in schemaFiles)
{
ServiceDescription sd = ServiceDescription.Read(wsdlFile);
foreach (XmlSchema embeddedXsd in sd.Types.Schemas)
schemaCollection.Add(embeddedXsd);
}
This is part of the wsdl file where the error is:
<s:schema elementFormDefault="qualified"
targetNamespace="http://www.myorg.se/webservices/">
<s:import namespace="http://microsoft.com/wsdl/types/" />
<s:element name="RequestIdHeader" type="tns:RequestIdHeader" />
<s:complexType name="RequestIdHeader">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="RequestId"
type="s3:guid" />
</s:sequence>
<s:anyAttribute />
</s:complexType>
</s:schema>
This is the Schema "header":
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions
xmlns:s0="http://www.myorg.se/WebServices/SaveStudentRequest.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
xmlns:s3="http://microsoft.com/wsdl/types/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:tns="http://www.myorg.se/webservices/"
xmlns:s1="http://www.myorg.se/WebServices/SaveStudentResponse.xsd"
xmlns:s="http://www.w3.org/2001/XMLSchema"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
targetNamespace="http://www.myorg.se/webservices/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
I am using .NET Framework 2.0 and I am aware of the XmlSchemaCollection
being obsolete, but it is what I need to use for now.
I read the 'BUG: Type "###" is not declared in reference to local type of an
included XSD Schema file' KB article but that solution does not seem
applicable to my case or perhaps I do not understand it correctly.
/Joakim
|