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.Seri alization.XmlTy peAttribute(Nam espace="http://ogsa.globus.org
/agreement-factory-service")]
[System.Xml.Seri alization.XmlRo otAttribute("Su pportedAgreemen tType",
Namespace="http ://ogsa.globus.org/agreement-factory-service",
Nullable=false)]
--
HTH
Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor
"Andre" <an*******@disc ussions.microso ft.com> wrote in message
news:9B******** *************** ***********@mic rosoft.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:
<SupportedAgree mentType 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><Q Name>price_per_ invocation</QName></price><serviceL evel><QNam
e>service_level </QName></serviceLevel><q osLevel><QName> qos_level</QName></qo
sLevel><minRequ ests><QName>min imal_requests</QName></minRequests></Supported
AgreementType>
The c# code:
class Class1
{
[STAThread]
static void Main(string[] args)
{
XmlSerializer serializer = new
XmlSerializer(t ypeof(Supported AgreementType)) ; TextReader tr = new StreamReader("c :\\test.xml");
SupportedAgreem entType sat =
(SupportedAgree mentType)serial izer.Deserializ e(tr); tr.Close();
}
}
public class SupportedAgreem entType
{
private string _qname;
SupportedTermTy pe _price;
SupportedTermTy pe _serviceLevel;
SupportedTermTy pe _qosLevel;
SupportedTermTy pe _minRequests;
public string QName
{
get{ return _qname; }
set{ _qname = value; }
}
public SupportedTermTy pe price
{
get{ return _price; }
set{ _price = value; }
}
public SupportedTermTy pe serviceLevel
{
get{ return _serviceLevel; }
set{ _serviceLevel = value; }
}
public SupportedTermTy pe qosLevel
{
get{ return _qosLevel; }
set{ _qosLevel = value; }
}
public SupportedTermTy pe minRequests
{
get{ return _minRequests; }
set{ _minRequests = value; }
}
}
public class SupportedTermTy pe
{
private string _qname;
private string _termValue;
public string QName
{
get{ return _qname; }
set{ _qname = value; }
}
public string termValue
{
get{ return _termValue; }
set{ _termValue = value; }
}
}