当参数超过某个(小)数时,服务调用失败

时间:2012-01-31 14:10:26

标签: c# web-services silverlight-4.0

我的Silverlight应用程序中有一个Webservice调用,当参数中的项目数量大约为2500时,它会失败。有人知道发生了什么吗?

将参数声明为可观察集合:

var pointIds = new System.Collections.ObjectModel.ObservableCollection<int>();

我称之为:

client.ServiceClient.MarkAllPointAsFavouriteAsync(Settings.Current.User.UserId,pointIds);

并且servicecall的定义如下:

public void MarkAllPointAsFavourite(Guid userId, List<int> pointIds)
    {
        PointRepository.MarkAllPointAsFavourite(userId, pointIds);
    }

为什么在使用大约2500个整数的列表调用时会失败?

给出的错误是:

System.ServiceModel.CommunicationException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
   at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
   at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
   at System.Net.Browser.AsyncHelper.<>c__DisplayClass4.<BeginOnUI>b__1(Object sendState)
   --- End of inner exception stack trace ---
   at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
   at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result)
   --- End of inner exception stack trace ---
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result)
   at Conwx.Net.Client.Framework.CustomerServiceReference.CustomerServiceClient.CustomerServiceClientChannel.EndMarkAllPointAsFavourite(IAsyncResult result)
   at Conwx.Net.Client.Framework.CustomerServiceReference.CustomerServiceClient.Conwx.Net.Client.Framework.CustomerServiceReference.ICustomerService.EndMarkAllPointAsFavourite(IAsyncResult result)
   at Conwx.Net.Client.Framework.CustomerServiceReference.CustomerServiceClient.OnEndMarkAllPointAsFavourite(IAsyncResult result)
   at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result)}

1 个答案:

答案 0 :(得分:0)

  

为什么在使用大约2500个整数的列表调用时会失败?

我发现它在列表中的大约2100项中失败了。这是因为它正在构建查询。

在这种情况下,由于您没有返回任何内容,您可以通过将定义更改为:

来使方法可以调用
[Invoke]
public void MarkAllPointAsFavourite(Guid userId, List<int> pointIds)
{
    PointRepository.MarkAllPointAsFavourite(userId, pointIds);
}

这避免了限制。

您还必须稍微修改一下调用代码。