XML Serialization Exception

  • Thread starter Abhishek Srivastava
  • Start date
A

Abhishek Srivastava

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.
 

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

Different Serialization Technique In .NET 0
XML Serialization of ListArray 5
Serialization 0
Xml Serialization Assembly 0
Tasks 1
Exception 0
Serialization Issue 11
webservice sending object - serialisation error 3

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top