-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Hi there.
Describe the bug
I am migrating a project from .Net Framework 4.7.2 to .NET 6.
And I am getting error in response when it is serialized.
System.ServiceModel.ProtocolException: There is a problem with the XML data received from the network. See the description of the inner exception for details. ---> System.Xml.XmlException: The data at the root level is invalid. Line 1, position 1.
I think this is due to the fact that the response does not support chunking.
I got response like this
20d
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:searchClientRs xmlns:ns2="........">
<messageHeader>
<messageId>689b1900-ef74-4352-90fd-d180d59c1a37</messageId>
<correlationId>689b1900-ef74-4352-90fd-d180d59c1a37</correlationId>
<responseStatus>
<code>0</code>
<textMessage/>
<warning xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</responseStatus>
</messageHead
33f
er>
<clients>
<client>
<bankId>1</bankId>
...Symbols "20d" and "33f" it's special symbol in chunked response, as far as I understand))
I tried using the TransferMode setting to enable chunking.
But neither the TransferMode.Stream setting nor the TransferMode.StreamResponse setting helped and returned the same error.
I found this code in source
namespace System.ServiceModel.Channels
{
internal class HttpResponseMessageHelper
{
...
private Task<Message> ReadStreamAsMessageAsync(TimeoutHelper timeoutHelper)
{
var content = _httpResponseMessage.Content;
Task<Stream> contentStreamTask = GetStreamAsync();
if (TransferModeHelper.IsResponseStreamed(_factory.TransferMode))
{
return ReadStreamedMessageAsync(contentStreamTask);
}
if (!content.Headers.ContentLength.HasValue)
{
return ReadChunkedBufferedMessageAsync(contentStreamTask, timeoutHelper);
}
return ReadBufferedMessageAsync(contentStreamTask);
}And I checked all three read methods.
They all throw the same exception.
To Reproduce
I'm working with a SOAP service that I don't have access to and it's written in Java.
So I don't know how to reproduce this code.
I can attach the full text of the response with headers.
Expected behavior
I expect that everything will work just as well as on the .NET Framework 4.7.2.
Additional context
Soap UI correctly parses this response.
