Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / June 2004

Tip: Looking for answers? Try searching our database.

Problem with returning custom ArrayList with webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Knecke - 28 Jun 2004 09:44 GMT
Hi all.

I have a problem with returning a custom Result object with
webservice.

The classes i use is described below (some fields and properties is
removed)

public class Result {
int statusCode;
object data;
}

public class Customer {
int customerNr
}

public class CustomerList : ArrayList {
//Implements the add method to only add Customer objects
}

And now to the webmethod

[WebMethod]
[XmlInlude(typeof(Customer))]
[XmlInlude(typeof(CustomerList))]
public Result GetCustomers() {
//Logic to find the customer is placed here....
//All the customers is placed in a variable called custList

res.data = custList;
res.statusCode = 1;

return res;
}

Now, when running this, this errormessage appears:

System.InvalidOperationException: The type Result may not be used in
this context. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
name, String ns, Object o, Boolean xsiType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3_Object(String
n, String ns, Object o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write7_Result(String
n, String ns, Result o, Boolean isNullable, Boolean needType) at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write10_GetSalesProjectTypesResponse(Object[]
p) --- End of inner exception stack trace --- at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle) at
System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces) at
System.Web.Services.Protocols.SoapServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream) at
System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke()

I also get the same error when trying to just return the CustomerList
and skip the Result object but instead the error says:

System.InvalidOperationException: The type CustomerList may not be
used in this context.

Please help!!!

//Jonas
Dino Chiesa [Microsoft] - 30 Jun 2004 05:51 GMT
this example shows how to return an array of "custom objects"
http://www.winisp.net/cheeso/srcview.aspx?file=Arrays.asmx

-D

> Hi all.
>
[quoted text clipped - 37 lines]
> this context. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String
> name, String ns, Object o, Boolean xsiType) at

Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3
_Object(String
> n, String ns, Object o, Boolean isNullable, Boolean needType) at

Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write7
_Result(String
> n, String ns, Result o, Boolean isNullable, Boolean needType) at

Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1
0_GetSalesProjectTypesResponse(Object[]
> p) --- End of inner exception stack trace --- at
> System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
[quoted text clipped - 15 lines]
>
> //Jonas

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.