Deserializing big xml request in version 1.0.0.0
See original GitHub issueI need to deserialize a big xml request from a client. For example, the client posts xml request to upload file (pdf or tif). He uses convert to base64 these files and sends it to a server.
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Send xmlns="http://www.somesite.com/fax/">
<Parameters xmlns="http://www.site.path.Applications.Fax.Core.Schemas.SendRequest">
<fileName xmlns="">somefilename.pdf</fileName>
<content xmlns="">**HERE_VERY_LONG_STRING_BASE_64_MORE_THAN_100k_chars**</content>
</Parameters></Send ></s:Body></s:Envelope>
There is no problem with deserialization on 0.9.9.6 such xml requests. After research code I found a place where appears the problem.
class SoapMessageEncoder
public async Task<Message> ReadMessageAsync(PipeReader pipeReader, int maxSizeOfHeaders, string contentType)
{
if (pipeReader == null)
{
throw new ArgumentNullException(nameof(pipeReader));
}
var stream = new PipeStream(pipeReader, false);
return await ReadMessageAsync(stream, maxSizeOfHeaders, contentType);
}
public Task<Message> ReadMessageAsync(Stream stream, int maxSizeOfHeaders, string contentType)
{
if (stream == null)
{
throw new ArgumentNullException(nameof(stream));
}
XmlReader reader = XmlDictionaryReader.CreateTextReader(stream, ReaderQuotas);
Message message = Message.CreateMessage(reader, maxSizeOfHeaders, MessageVersion);
return Task.FromResult(message);
}
The first method invoke
#if ASPNET_30
var requestMessage = await messageEncoder.ReadMessageAsync(httpContext.Request.BodyReader, 0x10000, httpContext.Request.ContentType);
#endif
In this place there is an incomplete reading of the stream because of this, an error will fall during deserialization because xml is not complete.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
XML Serialization: Problem deserializing an abstract property
This is the recommended way to support abstract classes. You can switch instances by element name and use multiple declarations like this: [ ......
Read more >generated code - XML Support (serialization, de- ...
Instantiating an entity and its containing objects from XML (for example XML that is written by a call to WriteXml()), is done by...
Read more >[SOLVED] XML Deserialization of a single XML file into ...
I am new to XML serialization/deserialization and need some help. I have a huge XML file (let's call it ItemDatabase.xml ), and inside...
Read more >Serialization and Deserialization
The error message I am given is this: Unable to find the assembly '[project_name] Version=1.0.0.0, Culture=neutral, PublicKeyToken =null'.
Read more >DataSet and DataTable security guidance - ADO.NET
In this article. Default restrictions when deserializing a DataSet or DataTable from XML; Safety with regard to untrusted input; Use DataAdapter ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, tomorrow i will publish the nuget package.
Of course, I tried to increase quota,
but it didn’t help and exception only with .net core 3.0 and more