question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deserializing big xml request in version 1.0.0.0

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
kotovaleksandrcommented, Dec 17, 2019

Okay, tomorrow i will publish the nuget package.

1reaction
BorisVezhykcommented, Dec 17, 2019

To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Of course, I tried to increase quota,

app.UseEndpoints(endpoints =>
			{
				endpoints.MapControllers();
				endpoints.UseSoapEndpoint<IFaxService>("/EntryPoint.asmx",
					new BasicHttpBinding
					{
						MaxReceivedMessageSize = int.MaxValue,
						ReaderQuotas = XmlDictionaryReaderQuotas.Max
					},
					SoapSerializer.XmlSerializer);
			});

but it didn’t help and exception only with .net core 3.0 and more

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found