Published on InterSystems Developer Community (https://community.intersystems.com)

Home > Reading large stream from %CSP.Request

Question
Chris Pursey · Jan 31, 2023

Reading large stream from %CSP.Request

We have created a number of REST adapters that extend %CSP.REST and these have been working fine.  However, we are now facing a problem with a new one where very large XML documents are being posted.  This is the pattern we are following:

Set inMsg = %request.Content.Read()

Set tSC = ##class(Ens.Director).CreateBusinessService("Epro_ItkHttp",.tBusinessService)

Set tSC = tBusinessService.ProcessInput(inMsg, .tBusinessServiceOutput)

However, when the %request is particularly long, it is being truncated, and working with %XML.Reader then fails in the business service class.

I believe the call to Read() is the problem.  If I call it with some arbitrarily long value - such as Read(500000) - then it works.

What is the correct approach here?  Is there any harm in putting in a massive number into the len parameter of the Read() method?  Or is there a way of looping through the stream and constructing the object to pass to the business service?

Any advice much appreciated.

#CSP #ObjectScript #REST API #InterSystems IRIS #InterSystems IRIS for Health
Product version: IRIS 2022.1
$ZV: IRIS for Windows (x86-64) 2022.1 (Build 209U) Tue May 31 2022 12:16:40 EDT [HealthConnect:3.5.0] [HealthConnect:3.5.0]

Source URL:https://community.intersystems.com/post/reading-large-stream-csprequest