我已經和web服務的WebMethod......可能不會在這個上下文中使用......而系列化
[webMethod]
[XMLInclude(typeof(ContractCar[]))
public object GetObjects(Cars[] cars)
{
return Translator.ToObjects(Facade.GetObjects(cars);
}
public static object GetObjects(Cars cars)
{
List<Car> cars =new List<Country(...fillingcollection)
return cars.ToArray(),
}
public static object ToObjects(object collection)
{
if(collection is Car[])
{
return ConvertModelCarsToContractCars(collection),
}
public ContractCar[] ConvertModelCarsToContractCars(Cars[] collection)
{
...there is rewriting pool...
}
我在客戶側得到例外:
有錯誤產生XML文檔。
我正在使用此功能來檢查我將發送給客戶端的集合,它的工作原理。
public static void SerializeContainer(object obj)
{
try
{
// Make sure even the construsctor runs inside a
// try-catch block
XmlSerializer ser = new XmlSerializer(typeof(object));
TextWriter w = new StreamWriter(@"c:\list.xml");
ser.Serialize(w, obj);
w.Close();
}
catch (Exception ex)
{
DumpException(ex);
}
}
有趣的是,當集合只有一個元素[的WebMethod]工作正常,但是當它越brokes
我仍然有錯誤:ModelCar []可能不會在此上下文中使用... – user278618 2010-04-28 14:51:27