Silverlight WCF抛出远程服务器返回一个错误:NotFound
本文关键字:一个 错误 NotFound 返回 WCF 服务器 Silverlight | 更新日期: 2023-09-27 18:08:25
我想弄清楚为什么会发生这种情况。这太奇怪了
以下是我的确切呼叫。每当我在车辆数据合约的末尾添加额外的数据时,我得到远程服务器返回一个错误:NotFound。打电话时选择。SaveVehiclesAsync (infoKey、数据);
From Silverlight Side
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; }
}
Not Found
是Silverlight上的一个通用错误,这可能意味着很多事情-跨域问题,任何来自网络的非200响应等。您可以做一些事情,例如在服务器端启用跟踪,或者使用Fiddler等工具查看网络流量,这些工具将为您提供有关错误的更多信息。
http://blogs.msdn.com/b/silverlightws/archive/2008/04/16/debugging-web-service-usage-in-silverlight-2.aspx上的帖子有一些信息,这些信息在调试Silverlight的WCF调用时很有用。
大多数时候发生这种错误,只需右键单击ASP。. NET IIS服务器图标,每次运行应用程序时在时钟附近打开并停止它。
尝试在服务器配置文件的末尾设置绑定配置-示例:
<endpoint
address=""
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="DuplexService.IDuplexService">
</endpoint>
,当然你必须配置一个相应的绑定——比如:
<bindings>
<pollingDuplexHttpBinding>
<binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
duplexMode="MultipleMessagesPerPoll"
maxOutputDelay="00:00:07"/>
</pollingDuplexHttpBinding>
</bindings>
好运。
确保您的wcf已启用跟踪。这通常是导致我出现问题的原因,这次也是如此。