我试图弄清楚为什么会这样。它超级奇怪
以下是我的确切电话。每当我在车辆数据合同的末尾添加那个额外的数据成员时,我都会得到远程服务器返回一个错误:NotFound。当调用 pick.SaveVehiclesAsync(infoKey, data);
从银光边
public void SaveVehicles(InfoKey infoKey, ObservableCollection<VehicleFullInfoModel> vehicleFullInfoCollection, EventHandler<SaveVehiclesEventArgs> callBack)
{
var pick = new **ProjectServiceClient**();
pick.SaveVehiclesCompleted += (sender, e) =>
{
if (callBack != null)
callBack(this, new SaveVehiclesEventArgs(e.Result, e.fault));
};
var data =
new ObservableCollection<VehicleFullInfo>(vehicleFullInfoCollection.Select(rec => rec.Data).ToList());
pick.SaveVehiclesAsync(infoKey, data);
}
------------- 来自 WCF 服务
public interface IProjectService
{
[OperationContract]
string SaveVehicles(InfoKey infoKey, IList<VehicleFullInfo> vehicleFullInfoCollection, out FaultContract fault);
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ProjectService : IProjectService
{
public string SaveVehicles(InfoKey infoKey, IList<VehicleFullInfo> vehicleFullInfoCollection, out FaultContract fault)
{
return PickVehicles.SaveVehicles(infoKey, vehicleFullInfoCollection, out fault);
}
}
--------- PickVehicles 类------
保存到文件
------------ 数据契约
[DataContract]
public class VehicleFullInfo
{
[DataMember]
public Vehicle Vehicle { get; private set; }
}
------ 车辆数据合同
[DataContract]
public class Vehicle
{
public Vehicle(Data vehicleData, int index)
{
}
[DataMember]
public string VehicleNumber { get; set; }
[DataMember]
public bool? IsVehicleFromPolicy { get; private set; }
[DataMember]
public bool? IsInclude { get; set; }
[DataMember]
public string VIN { get; set; }
[DataMember]
public VehicleTypeEnum Type { get; set; }
[DataMember]
public int? ModelYear { get; set; }
[DataMember]
public VehicleMake Make { get; set; }
[DataMember]
public string Model { get; set; }
[DataMember]
public bool? HasAntiTheft { get; set; }
[DataMember]
public AirBagTypeEnum AirBagType { get; set; }
[DataMember]
public int? GarageZip { get; set; }
[DataMember]
public VehicleUseTypeEnum VehicleUseType { get; set; }
[DataMember]
public int? Miles { get; set; }
[DataMember]
public int? TrailerValue { get; set; }
[DataMember]
public bool? IsMotorhomeSold { get; set; }
[DataMember]
public int? TrailerCamperLength { get; set; }
[DataMember]
public string TrailerDesc { get; set; }
[DataMember]
public int? TrailerGrossWeight { get; set; }
[DataMember]
public string ExtraField { get; set; }
}