Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > IList deserialization

Reply
Thread Tools

IList deserialization

 
 
Vladner
Guest
Posts: n/a
 
      04-04-2007
I have a class with a property of IList type and a webmethod with parameter
of this class.
When I try to invoke the webmethod passing an instance of this class, I
receive the error below.

System.Web.Services.Protocols.SoapException: Server was unable to read
request. ---> System.InvalidOperationException: There is an error in the XML
document. ---> System.InvalidOperationException: Could not deserialize
global::System.Collections.IList. Parameterless constructor is required for
collections and enumerators.
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read9_Operador(Boolean isNullable, Boolean checkType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlS erializationReader1.Read33_localizarOperador()
at
Microsoft.Xml.Serialization.GeneratedAssembly.Arra yOfObjectSerializer36.Deserialize(XmlSerialization Reader reader)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader
xmlReader, String encodingStyle)
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.SoapServerProtocol.R eadParameters()
at System.Web.Services.Protocols.WebServiceHandler.Co reProcessRequest()

Any Ideas ?

Vládner
 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      04-04-2007
"Vladner" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
>I have a class with a property of IList type and a webmethod with parameter
> of this class.
> When I try to invoke the webmethod passing an instance of this class, I
> receive the error below.

....
> Any Ideas ?


There are no instances of interfaces. There are instances of classes which
implement an interface, but there are no instances of interfaces.

If there is no instance, then you can't serialize it!

John

P.S. You should consider not passing platform-specific types as parameters
or return values of web services. Even if you intend to stick with Windows
clients only today, in the future you might need to support something like
PHP or Perl.


 
Reply With Quote
 
 
 
 
Vladner
Guest
Posts: n/a
 
      04-05-2007
Actually, the serialization is of the object that has a property of IList
type. In VS2003 (Framework 1.1) the same example works fine. I think this is
something different in framework 2.0 (VS 2005). The compilation passes, but a
runtime error ocurrs at the Webmethod call.

About the use of specific types... I'm responsible for an evaluation of a
migration from VS2003 to VS2005. So, the situation appeared in one of chosen
legacy system.

I created an separate solution for simulation:

There are two projects: A WebService and a WebApplication. The Webservice
has a class named Customer with a property of IList type and a WebMethod that
just receive as parameter one instance of Customer. The client has just a
call of the Webmethod passing one instance of this class.

I'm posting codes that simulate the error.

**** WebMethod ******************

[WebMethod]
public void GetCust(Customer c){

}

**** Customer class - WebService Project ****

public class Customer
{
public Cliente()
{
}
private string strName;
private IList lstFriends;

public string Name
{
get
{
return strName;
}
set
{
this.strName= value;
}
}

public IList Friends
{
get
{
return lstFriends;
}
set
{
this.lstFriends = value;
}
}

}

**** Page_load - WebApplication****

localhost.Service1 srv = new localhost.Service1();
localhost.Customer c = new localhost.Customer();

srv.GetCust(c);


P.S.: If, instead of the IList, I use ArrayList as a property type
everything works fine.

Vladner


"John Saunders" wrote:

> "Vladner" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> >I have a class with a property of IList type and a webmethod with parameter
> > of this class.
> > When I try to invoke the webmethod passing an instance of this class, I
> > receive the error below.

> ....
> > Any Ideas ?

>
> There are no instances of interfaces. There are instances of classes which
> implement an interface, but there are no instances of interfaces.
>
> If there is no instance, then you can't serialize it!
>
> John
>
> P.S. You should consider not passing platform-specific types as parameters
> or return values of web services. Even if you intend to stick with Windows
> clients only today, in the future you might need to support something like
> PHP or Perl.
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to get the ContentPlaceHolders IList of a MasterPage bruce barker ASP .Net 1 12-19-2006 08:13 AM
Can I convert IList to a DataSet, DataTable or DataView? =?Utf-8?B?Tmljaw==?= ASP .Net 6 07-19-2006 06:39 PM
question about proper way to show an IList of objects? Flip ASP .Net 1 03-28-2005 06:17 PM
Need to pass a method an Ilist DaveF ASP .Net 1 12-08-2004 02:56 PM
Implement IList Interface frank ASP .Net 0 07-11-2003 09:03 AM



Advertisments