简体   繁体   English

C#肥皂客户端System.OverflowException:算术运算导致溢出

[英]C# soap client System.OverflowException: Arithmetic operation resulted in an overflow

928mb file works ok, but this overflow error happens when I try to send 1.08GB to the soap service (mtom chunked transfer, _service reference.cs is generated from wsdl). 928mb文件可以正常工作,但是当我尝试向soap服务发送1.08GB时会发生此溢出错误(mtom分块传输,_service reference.cs是从wsdl生成的)。 In the fiddler tracing I see only headers of the request, but no request body and no response 在提琴手跟踪中,我仅看到请求的标头,但没有请求主体,也没有响应

Relevant code: 相关代码:

var httpsTransportBindingElement = new HttpsTransportBindingElement
{
    MaxReceivedMessageSize = int.MaxValue,
    TransferMode = TransferMode.Streamed //Chunked transfer
};
var binding = new CustomBinding();
var mtomEncoding = new MtomMessageEncodingBindingElement(MessageVersion.Soap12, Encoding.UTF8);
mtomEncoding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
binding.Elements.Add(mtomEncoding);
binding.Elements.Add(httpsTransportBindingElement);
binding.SendTimeout = TimeSpan.FromHours(1);
binding.ReceiveTimeout = TimeSpan.FromMinutes(5);
_service = new FileuploadSoapPortTypeClient(binding, new EndpointAddress(configuration.HttpUploadUrl));
_service.PostFile(request);

And the error stacktrace is as follows: 错误堆栈跟踪如下:

System.OverflowException: Arithmetic operation resulted in an overflow. 

Server stack trace: 
at System.IO.BufferedStream.Write(Byte[] array, Int32 offset, Int32 count) 
at System.Xml.XmlMtomWriter.WriteXOPBinaryParts() 
at System.ServiceModel.Channels.Message.WriteMessagePostamble(XmlDictionaryWriter writer) 
at System.ServiceModel.Channels.MtomMessageEncoder.WriteMessage(Message message, Stream stream, String startInfo, String boundary, String startUri, Boolean writeMessageHeaders) 
at System.ServiceModel.Channels.HttpOutput.WriteStreamedMessage(TimeSpan timeout) 
at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout) 
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout) 
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) 
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) 
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) 
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) 
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) 

Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) 
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 
at MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request) 
at MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request) in C:\MyServiceClient\Reference.cs:line 8473 

I cant debug this further than to the PostFile() call, so my question is - where does the error occur, in the server or on my client? 除了对PostFile()调用之外,我无法进行进一步的调试,所以我的问题是-服务器或客户端上的错误发生在哪里? and of course how to go about fixing it? 当然要怎么解决呢? Thanks! 谢谢!

From in the stack trace it is telling you that it is server side: 从堆栈跟踪中,它告诉您它是服务器端:

Server stack trace:

The error is caused by something which is happening at: 该错误是由以下情况引起的:

at MyServiceClient.FileuploadSoapPortType.PostFile(UploadRequest request) in C:\MyServiceClient\Reference.cs:line 8473 

Access that file and see what is happening on that line. 访问该文件并查看该行发生了什么。 I'd like to think where ever the web service is hosted they have logs for when something like this occurs. 我想考虑一下,无论在何处托管Web服务,它们都有发生此类情况时的日志。

To find out why I suggest: 为了找出为什么我建议:

  • giving the time it occured ( if they have logs its easier to find the stack trace) 给出发生的时间(如果他们有日志,则更容易找到堆栈跟踪)
  • Detailed description of what you tried to do when the error occurred. 错误发生时您尝试执行的操作的详细说明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM