从Silverlight向WCF数据服务发布1.4KB字符串时出错

时间:2012-11-28 22:36:52

标签: silverlight wcf-data-services

我正在使用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,Boolean handleWebException)    在System.Data.Services.Client.QueryResult.AsyncEndGetResponse(IAsyncResult asyncResult)    ---内部异常堆栈跟踪结束---    at System.Data.Services.Client.BaseAsyncResult.EndExecute [T](Object source,String method,IAsyncResult asyncResult)    在System.Data.Services.Client.QueryResult.EndExecuteQuery [TElement](对象源,String方法,IAsyncResult asyncResult)    at System.Data.Services.Client.DataServiceRequest.EndExecute [TElement](对象源,DataServiceContext上下文,String方法,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 }
            );

1 个答案:

答案 0 :(得分:0)