WebService, object inheritance, serialization errors

Discussion in 'ASP .Net Web Services' started by Jay Douglas, Sep 13, 2007.

  1. Jay Douglas

    Jay Douglas Guest

    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
     
    Jay Douglas, Sep 13, 2007
    #1
    1. Advertising

  2. Jay Douglas

    realapak Guest

    Same issue for me... Any solution?
     
    realapak, Sep 27, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    965
    Mark Goldin
    Jan 17, 2004
  2. Replies:
    8
    Views:
    2,253
    deadsea
    Jan 2, 2005
  3. Replies:
    3
    Views:
    1,035
  4. Dimitri Ognibene
    Replies:
    4
    Views:
    785
    Dimitri Ognibene
    Sep 2, 2006
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    403
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page