XML não pode ser validado devido a uma string codificada em Base64 muito grande
Eu tenho um serviço SOAP criado usando C # no Visual Studio 2017 compilado com a estrutura .NET 4.0.
Implantei o serviço no IIS Express ao depurar e em um site gerenciador do IIS. Em ambos os serviços, recebo o seguinte erro ao postar um XML com uma (grande) string codificada em Base64 (um arquivo PDF) de 8,1 milhões de caracteres:
System.Web.Services.Protocols.SoapException: o
servidor não conseguiu processar a solicitação.
Referência de objeto não definida para uma instância de um objeto.
em System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement () em System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest () em System.Web.Services.Protialize.SoapServerProtocol.Initialize ()
em System.Web.Services. .ServerProtocolFactory.Create (tipo de tipo, contexto HttpContext, solicitação HttpRequest, resposta HttpResponse, Booleano e abortProcessing)
I've already tried increasing the "Maximum allowed content length" to about 3GB in both the web.config file and the applicationhost.config file. This had no influence, but I also did not expect any result there because the error does not actually state that it has a problem that the content is too big.
When I post the same XML with another Base64 string which is a lot smaller it does create a correct Object from the XML without any problems.
I've also checked if the Base64 string is correct with multiple online converters. They also had a lot of problems with the size, but I could confirm the string.
The strange thing is that when debugging it does not even go into the WebService class.
By the way the field in code is a byte array and in the XSD defined as base64Binary.
I cannot share the Base64 string itself, because it has sensitive information in this case and also because it's size.
How can I solve this issue?
UPDATE Also tried setting "User the 64 bit version of IIS Express for web sites and projects", but this didn't help eather.
Respostas
The problem was the maximum request length. The size of the XML was longer then the default limit set in IIS. This resulted in cutting the XML, which resulted in an invalid/incomplete XML file.
Changing this configuration can be done directly in the web.config file:
<system.web>
<httpRuntime maxRequestLength="2147483647" />
</system.web>
Or in IIS manager:
- Open the site
- Open Configuration editor
- In the section go to system.web/httpRuntime
- Change the maxRequestLength property