【问题标题】:Error posting 1.4KB string from Silverlight to WCF Data Service将 1.4KB 字符串从 Silverlight 发布到 WCF 数据服务时出错
【发布时间】:2012-11-28 22:36:52
【问题描述】:

我正在使用 SL 5 和 WCF DS 5。我正在调用服务 POST 操作,其中将字符串作为输入发送,该输入基本上是文本文件的内容。似乎当字符串较小时,它可以工作,但是当它大约为 1.4KB(文本文件的大小)时,会抛出此错误:

{System.InvalidOperationException: An error occurred while processing this request. ---> System.Exception: Error HRESULT E_FAIL has been returned from a call to a COM component.

在 System.Net.Browser.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 在 System.Data.Services.Http.ClientHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) 在 System.Data.Services.Client.HttpWebRequestMessage.EndGetResponse(IAsyncResult asyncResult) 在 System.Data.Services.Client.HttpTransportLayer.EndGetResponse(IODataRequestMessage requestMessage,IAsyncResult asyncResult) 在 System.Data.Services.Client.DataServiceContext.GetResponseHelper(ODataRequestMessageWrapper 请求,IAsyncResult asyncResult,布尔句柄WebException) 在 System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult) --- 内部异常堆栈跟踪结束 --- 在 System.Data.Services.Client.BaseAsyncResult.EndExecute[T](对象源,字符串方法,IAsyncResult asyncResult) 在 System.Data.Services.Client.QueryResult.EndExecuteQuery[TElement](对象源,字符串方法,IAsyncResult asyncResult) 在 System.Data.Services.Client.DataServiceRequest.EndExecute[TElement](对象源,DataServiceContext 上下文,字符串方法,IAsyncResult asyncResult) 在 System.Data.Services.Client.DataServiceContext.EndExecute[TElement](IAsyncResult asyncResult)

我从 WPF 应用程序中调用了相同的操作,它运行良好。我也在 WCF DS 主机上这样做了:

WebHttpBinding binding = new WebHttpBinding();
        binding.MaxReceivedMessageSize = int.MaxValue;
        binding.MaxBufferPoolSize = int.MaxValue;
        binding.MaxBufferSize = int.MaxValue;
        binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;

这是来自 SL 客户的电话:

CodeFirstContainer context;

        context = new CodeFirstContainer(new Uri("http://localhost:4444/MyDataService/"));

        OperationParameter p = new UriOperationParameter("fileIDN", fileIDN);
        OperationParameter p1 = new UriOperationParameter("**fileContent**", responseContent);

        context.BeginExecute<int>
            (new Uri(context.BaseUri.OriginalString + "ProcessTextFile"),
                (r) =>
                {
                    Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        try
                        {
                            context = r.AsyncState as CodeFirstContainer;

                            // Get the response of the query.
                            var response = context.EndExecute<int>(r).ToList();
                        }
                        catch (Exception ex)
                        {
                        }
                    }
                    );
                },
                context, "POST", true, new OperationParameter[] { p, p1 }
            );

【问题讨论】:

    标签: silverlight wcf-data-services


    【解决方案1】:
    猜你喜欢
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多