WebService, object inheritance, serialization errors

J

Jay Douglas

I'm attempting to create one continuous xsd type with 2 C# objects, one of
which that inherits from each other. When ASP.net 2.0 serializes either
version of the webservice objects, along with the base object, it says that
these objects have the same type name and need to be in different name
spaces. The problem is, that when different namespaces are used, the XML
required to submit a request needs to detail both namespaces, which is
cumbersome. I would like to use the namespace from just the derived object,
allowing for no namespace declaration on the base class.



I have read many different posts across newsgroups and websites referring to
this issue but still havn't found a solution that fits my requirements. I'm
hoping that somebody can help.



Is there any way to tell the ASP.net 2.0 serializer to basically flatten
these objects into one complex type?



(Supporting Exception and code follows)



Exception:



Types 'ServiceObjects._2_5.Adapters.TestMeBase' and
'ServiceObjects._2_6.TestMe' both use the XML type name, 'TestMe', from
namespace 'http://test/2'. Use XML attributes to specify a unique XML name
and/or namespace for the type.



Web Service Code:



[WebMethod]

public bool TestMethod(ServiceObjects._2_6.TestMe testObj)

{

return true;

}



Base Class:



[XmlType("TestMe")]

public class TestMeBase

{

public string BaseStr;

}



Derived Class:



[XmlType("TestMe", Namespace="http://test/2")]

public class TestMe : ServiceObjects._2_5.Adapters.TestMeBase

{

public string DerivedStr;

}



Thanks for reading through this post:

Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top