RE: web service error - urgent
- From: Claus Konrad [MCSD] <ClausKonradMCSD@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 10 Nov 2006 12:36:01 -0800
What is "ports" anyway? I don't see this defined anywhere in your method.
(return ports;)?
What about this instead (return an array of Cars):
return carList.ToArray(typeof(Car));
--
rgds.
/Claus Konrad
MCSD.NET (C#)
"igotyourdotnet" wrote:
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?
- Follow-Ups:
- RE: web service error - urgent
- From: igotyourdotnet
- RE: web service error - urgent
- References:
- web service error - urgent
- From: igotyourdotnet
- web service error - urgent
- Prev by Date: web service error - urgent
- Next by Date: RE: web service error - urgent
- Previous by thread: web service error - urgent
- Next by thread: RE: web service error - urgent
- Index(es):
Relevant Pages
|