1

I have a SOAP service created using C# in Visual Studio 2017 compiled with .NET 4.0 framework.

I deploy the service to IIS Express when debugging and to a IIS manager Site. On both services I'm running into the following error when I post a XML with a (big) Base64 encoded string (a PDF file) of 8.1 million characters:

System.Web.Services.Protocols.SoapException:
Server was unable to process request.
Object reference not set to an instance of an object.
at System.Web.Services.Protocols.SoapServerProtocolHelper.GetRequestElement() at System.Web.Services.Protocols.Soap12ServerProtocolHelper.RouteRequest() at System.Web.Services.Protocols.SoapServerProtocol.Initialize()
at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& 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.

Remi
  • 1,289
  • 1
  • 18
  • 52
  • 1
    Please show the relevant code. – itsme86 Sep 22 '20 at 14:50
  • 1
    @itsme86 there is no relevant code, because as I said when debugging it does not even enter the WebService class and with a smaller Base64 string it does and everything works fine. – Remi Sep 22 '20 at 14:55
  • If there is no code, can you at least [edit] your question to share the full `ToString()` output of the exception including the exception type, message, traceback and inner exception(s) if any? – dbc Sep 22 '20 at 15:15
  • You first have to decode the base 64 string before using deserializaton. Write your own code to deserialize. The size should be a factor in your own code. See Wiki : https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64 – jdweng Sep 22 '20 at 15:39
  • Absent a [mcve] I can only guess that this might help: [IIS Express - increase memory limit](https://stackoverflow.com/a/35814763/3744182). – dbc Sep 22 '20 at 15:57
  • @dbc I've updated the full error message and also tried the 64bit setting, but didn't help. – Remi Sep 23 '20 at 06:50

1 Answers1

0

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:

  1. Open the site
  2. Open Configuration editor
  3. In the section go to system.web/httpRuntime
  4. Change the maxRequestLength property
Remi
  • 1,289
  • 1
  • 18
  • 52