Question
· May 18, 2021

Error <MAXSTRING> (Stream to %xsd.base64Binary)

Hello everyone :-) A colleague wants to use data got from a stream into another type of object: %xsd.base64Binary (related to a webservice context).
His code works for regular data, but the following error appears when parsing large streams (~43 MB): "ERREUR #5002: Erreur Cache:    <MAXSTRING>"

Here is below his code:

Class (...).StampDataRequest Extends Ens.Request [ ProcedureBlock ]
{

Property DocumentData As %xsd.base64Binary;

}

Method OnRequest(pRequest As Ens.StreamContainer, Output pResponse As Ens.Response) As %Status
{              
       ...

       set fileStream = ##class(%Stream.GlobalCharacter).%New()

do fileStream.CopyFromAndSave(pRequest.Stream)

//fileStream contains bytes from pRequest
            
set tsRequest = ##class((...).StampDataRequest).%New()

       do fileStream.Rewind()
       while 'fileStream.AtEnd 
                   set tsRequest.DocumentData = tsRequest.DocumentData_fileStream.Read(30000)
        }
        …

}


What should he change in this code for not to have this size limitation ?

Best regards,

Mathieu

Product version: HealthShare 2017.2
$ZV: Cache for Windows (x86-64) 2018.1.4 (Build 505_1U) Thu May 28 2020 10:01:40 EDT
Discussion (9)1
Log in or sign up to continue

Hi

Your request class tsRequest has a property DocumentData which I assume has a data type of %String. There is one thing you need to check and to things you can do in the request class:

1) Make sure that the setting for "Support Long Strings" setting in your Cache Instance is set to true. The setting can be found in the Management Portal at System Administration > Configuration > System Configuration > Memory and Startup
 

2) in the class definition for your request class use the following definition for your DocumentData specify the definition as follows:

Property DocumentData as %String(MAXLEN="", TRUNCATE);

Turning on Long Srinngs enables you to store up to 3,641,144 characters.

The Attribute MAXLEN="" says the Maximum Length of the property is the maximum string length supported i.e. 3,641,144 characters. 

The TRUNCATE attribute will chop off any characters that exceed the MAXLEN without throwing a MAXSTRING error

Nigel

Hello,

In the client classes of the external  webservice, i  changed for the "DocumentData" property, in several places, ,"%xsd.base64Binary" to "%Stream.GlobalCharacter". I recompiled the classes.

After this, in the "Ensemble" connector, i had to do the conversion to Base64 imyself.

Indeed, with "%xsd.base64Binary" the conversion to base64 was done automatically during the transfer.

Now, in my example, fileStream is a base64 stream, and here's how my "DocumentData" property is assigned:

do tsRequest.DocumentData.CopyFrom (fileStream)

I tested and the return from the remote webservice is correct with the same hashing values.

Thank you very much for your help.