The serializer doesn't know about the Xml namespace since the .NET Type
doesn't declare it.
You need to add the following attributes to make sure the serializer will
consider the namespace:
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://ogsa.globus.org
/agreement-factory-service")]
[System.Xml.Serialization.XmlRootAttribute("Support edAgreementType",
Namespace="http://ogsa.globus.org/agreement-factory-service",
Nullable=false)]
--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor
"Andre" <an*******@discussions.microsoft.com> wrote in message
news:9B**********************************@microsof t.com...
Christoph,
Here is the full code listing. As mentioned before everything works fine
as long as the xmlns="http://ogsa.globus.org/agreement-factory-service" is
NOT included in the xml. Thanks for any comments.
Andre
test.xml:
<SupportedAgreementType xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ogsa.globus.org/agreement-factory-service"><QName>agreement01<
/QName><price><QName>price_per_invocation</QName></price><serviceLevel><QNam
e>service_level</QName></serviceLevel><qosLevel><QName>qos_level</QName></qo
sLevel><minRequests><QName>minimal_requests</QName></minRequests></Supported
AgreementType>
The c# code:
class Class1
{
[STAThread]
static void Main(string[] args)
{
XmlSerializer serializer = new
XmlSerializer(typeof(SupportedAgreementType)); TextReader tr = new StreamReader("c:\\test.xml");
SupportedAgreementType sat =
(SupportedAgreementType)serializer.Deserialize(tr) ; tr.Close();
}
}
public class SupportedAgreementType
{
private string _qname;
SupportedTermType _price;
SupportedTermType _serviceLevel;
SupportedTermType _qosLevel;
SupportedTermType _minRequests;
public string QName
{
get{ return _qname; }
set{ _qname = value; }
}
public SupportedTermType price
{
get{ return _price; }
set{ _price = value; }
}
public SupportedTermType serviceLevel
{
get{ return _serviceLevel; }
set{ _serviceLevel = value; }
}
public SupportedTermType qosLevel
{
get{ return _qosLevel; }
set{ _qosLevel = value; }
}
public SupportedTermType minRequests
{
get{ return _minRequests; }
set{ _minRequests = value; }
}
}
public class SupportedTermType
{
private string _qname;
private string _termValue;
public string QName
{
get{ return _qname; }
set{ _qname = value; }
}
public string termValue
{
get{ return _termValue; }
set{ _termValue = value; }
}
}