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.
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.