Silverlight WCF抛出远程服务器返回错误:NotFound

时间:2013-04-09 22:20:47

标签: c# .net wcf silverlight

我想弄清楚为什么会这样。它超级怪异

以下是我的确切电话。每当我在车辆datacontract的末尾添加额外的datameber时,我得到远程服务器返回错误:NotFound。当调用pick.SaveVehiclesAsync(infoKey,data);

来自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 Class -------

保存到文件

------------数据合同

[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; }
}

4 个答案:

答案 0 :(得分:3)

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调用时有用的信息。

答案 1 :(得分:1)

大多数情况下会发生此错误,只需右键单击每次在时钟附近运行应用程序时打开的ASP.NET IIS服务器图标并停止它。

然后再试一次。

答案 2 :(得分:0)

尝试在服务器配置文件的终点设置绑定配置 - 示例:

 <endpoint
           address=""
           binding="pollingDuplexHttpBinding"
           bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
           contract="DuplexService.IDuplexService">
</endpoint>

但当然你必须配置相应的绑定 - 例如:

<bindings>
        <pollingDuplexHttpBinding>
          <binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
                   duplexMode="MultipleMessagesPerPoll"
                   maxOutputDelay="00:00:07"/>
        </pollingDuplexHttpBinding>
</bindings>
祝你好运。

答案 3 :(得分:0)

Make sure your wcf has tracing enabled。 这通常是导致我出现问题的原因,这也是这次的原因。