web service error - urgent



I'm creating a web service this is going to return an arraylist of items.
When I try and run it Im' getting the following error message:
System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: The type Car List 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
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType)
at
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write3_ArrayOfAnyType(Object o)
at
Microsoft.Xml.Serialization.GeneratedAssembly.ArrayListSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter,
Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter
textWriter, Object o)
at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse
response, Stream outputStream, Object returnValue)
at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[]
returnValues, Stream outputStream)
at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[]
returnValues)
at System.Web.Services.Protocols.WebServiceHandler.Invoke()


here is my code Im' trying to use.
[WebMethod]
[return: System.Xml.Serialization.XmlArrayItem(typeof(Cars))]
public ArrayList CarList
{
string sql = "SELECT * from Cars";
SqlConnection conn = new
SqlConnection(ConfigurationManager.AppSettings["connectMe"]);
SqlCommand cmd = new SqlCommand(sql, conn);
conn.Open();
SqlDataReader reader;
reader = cmd.ExecuteReader();

ArrayList carList= new ArrayList();
while (reader.Read())
{
Cars car = new Cars
car.make= eader.GetString(1);
car.model= reader.GetString(2);
carList.Add(car)
}
reader.Close();
conn.Close();

return ports;
}

public class Cars
{
public string make;
public string cars;
}

what am i missing or doing wrong?
.



Relevant Pages

  • RE: web service error - urgent
    ... When I try and run it Im' getting the following error message: ... Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) ... Cars car = new Cars ... public string make; ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: web service error - urgent
    ... What is "ports" anyway? ... What about this instead (return an array of Cars): ... Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) ... public string make; ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: web service error - urgent
    ... What about this instead (return an array of Cars): ... Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) ... public string make; ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Accelerating rocket/light beam question
    ... There is a string connecting the two cars. ... Think, for a moment, about a system consisting of two rockets B and C ... F be the frame of your cars. ...
    (sci.physics.research)
  • Re: variable length fields for flexibility in subroutines
    ... private string _IntBlock; ... public string IBreturn ... public string IBstreet ...
    (comp.lang.cobol)