XML Serialization Exception

Discussion in 'ASP .Net' started by Abhishek Srivastava, Mar 1, 2004.

  1. Hello All,

    I am writing a XML WebService. I have two very simpilar methods exposed
    as webService. GetPersonList and GetModuleList.

    The GetPersonList method returns an ArrayList containing PersonVO(id,
    name, fullname) object. And GetModuleList returns and ArrayList
    containing the ModuleVO (id, module name) object.

    The GetPersonList works absolutely fine. But the GetModule List throws
    the following exception

    -------------
    UT.ServiceUT.GetModuleList : System.Web.Services.Protocols.SoapException
    : System.Web.Services.Protocols.SoapException: Server was unable to
    process request. ---> System.InvalidOperationException: There was an
    error generating the XML document. --->
    System.InvalidOperationException: The type CommonComponents.ModuleVO was
    not expected. Use the XmlInclude or SoapInclude attribute to specify
    types that are not known statically.
    at
    System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
    name, String ns, Object o, Boolean xsiType)
    at
    ------------

    Funny thing is that if I go an add the following method to my asmx.cs
    file (WITH NO OTHER CHANGES WHATSOEVER)

    [WebMethod]
    public void Junk(ModuleVO vo)
    {
    }

    The my method GetModuleList works absolutely fine!!

    I think the problem is that PersonVO appears in one of the parameter of
    a function. so the serializer knows about it. But ModuleVO doesn't
    (since the return type is an ArrayList now an ModuleVO[])

    the JunkMethod tells the serializer about my ModuleVO object. so then my
    method GetModuleList begins to work as well.

    When I look at my web reference in the object browser, I can see that
    the web reference has proxies for the PersonVO but not for ModuleVO.
    (when the junk method is not there)

    How to overcome the problem? How can I tell the serializer about my
    ModuleVO object. Without the hacking like adding the Junk Method.

    Thanks for your help in advance.

    regards,
    Abhishek.
     
    Abhishek Srivastava, Mar 1, 2004
    #1
    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. Replies:
    8
    Views:
    2,273
    deadsea
    Jan 2, 2005
  2. Replies:
    3
    Views:
    1,056
  3. Dimitri Ognibene
    Replies:
    4
    Views:
    796
    Dimitri Ognibene
    Sep 2, 2006
  4. Abhishek Srivastava

    XML Serialization Exception

    Abhishek Srivastava, Mar 1, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    142
    Dan Rogers
    Nov 11, 2004
  5. Ramunas Urbonas
    Replies:
    1
    Views:
    412
    Dino Chiesa [Microsoft]
    Jul 27, 2004
Loading...

Share This Page