Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserializing big xml request in version 1.0.0.0 #380

Closed
BorisVezhyk opened this issue Dec 16, 2019 · 10 comments
Closed

Deserializing big xml request in version 1.0.0.0 #380

BorisVezhyk opened this issue Dec 16, 2019 · 10 comments

Comments

@BorisVezhyk
Copy link

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.

kotovaleksandr pushed a commit to kotovaleksandr/SoapCore that referenced this issue Dec 17, 2019
@kotovaleksandr
Copy link
Member

@BorisVezhyk System.ServiceModel.QuotaExceededException : The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.?

Try increase quotas in binding declaration passed to UseSoapEndpoint method. Like this: https://github.com/kotovaleksandr/SoapCore/blob/develop/src/SoapCore.Tests/Serialization/ServiceFixture.cs

@BorisVezhyk
Copy link
Author

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

@kotovaleksandr
Copy link
Member

@BorisVezhyk Whats text of exception?

@BorisVezhyk
Copy link
Author

@BorisVezhyk Whats text of exception?

Exception appears when service tries to deserialize request
Message = "Unexpected end of file. Following elements are not closed: Content, Document, Parameters, Send, Body, Envelope. Line 1, position 342."
but request is right without problems and it works on 2.1

kotovaleksandr pushed a commit to kotovaleksandr/SoapCore that referenced this issue Dec 17, 2019
@kotovaleksandr
Copy link
Member

@BorisVezhyk Please check again on my fork

@BorisVezhyk
Copy link
Author

@BorisVezhyk Please check again on my fork

While I will check it out, Could you tell me where the issue is? My service get request is right without exception but on client-side on void method exception:

"The one-way operation returned a non-null message with Action=''."

This method has attribute one-way=true; and I tried to set my method
[OperationContract(IsOneWay = true)]
but it doesn't help.

@kotovaleksandr
Copy link
Member

@BorisVezhyk Please check again on my fork

While I will check it out, Could you tell me where the issue is? My service get request is right without exception but on client-side on void method exception:

"The one-way operation returned a non-null message with Action=''."

This method has attribute one-way=true; and I tried to set my method
[OperationContract(IsOneWay = true)]
but it doesn't help.

yes, it's bug. Please, create one more issue:)

@kotovaleksandr
Copy link
Member

@BorisVezhyk Please check again on my fork

While I will check it out, Could you tell me where the issue is? My service get request is right without exception but on client-side on void method exception:

"The one-way operation returned a non-null message with Action=''."

This method has attribute one-way=true; and I tried to set my method
[OperationContract(IsOneWay = true)]
but it doesn't help.

check on my fork OneWay operations, should be works

@BorisVezhyk
Copy link
Author

check on my fork OneWay operations, should be works

I checked all. Good job. Big xml request works and OneWay too!

@kotovaleksandr
Copy link
Member

Okay, tomorrow i will publish the nuget package.

CameronS29 pushed a commit to CameronS29/Soap-.NET-Core that referenced this issue May 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants