Web Connection
Web Connect and VFP String Limit
Gravatar is a globally recognized avatar based on your email address. Web Connect and VFP String Limit
  Scott R
  All
  Oct 10, 2018 @ 10:30am

Rick,

Inside of web connect, I have a string I am returning that is approx 25 Mb+. I've followed your instructions in https://west-wind.com/wconnect/weblog/ShowEntry.blog?id=882 on how to manipulate / get around VFP's 16 Mb limit. i.e.

m.retval = ''
	
	SELECT tMonths
	SCAN 
		SELECT cpLogHold.* ;
			FROM cpLogHold ;
			WHERE MONTH(cplogHold.dt) = tMonths.month ;
				AND YEAR(cpLogHold.dt) = tMonths.year ;
			INTO CURSOR tLogHold
			
			SELECT tLogHold
			CURSORTOXML('tLogHold', 'm.hold', 1, 2, 0, '1') && inline schema, so 1 is treated as a numeric, not a logical
			
			m.retval = m.retval + '|R|' + m.hold
	ENDSCAN && tMonths
	
	* Response looks like: '|R|<XML DATA.../>|R|<More XML Data.../>|R|
	m.retval = m.retval + '|R|'

That is working great. The problem I now have is in the Web Connect Framework. I'm doing

JsonService.IsRawResponse = .T.   && use Response output

response.write(m.retval)
response.end()

I'm getting back

{"isCallbackError":true,"message": "String is too long to fit.\rProc: write\rLine No: 119\rLine Contents: THIS.cOutput = this.cOutput + lcText" }

Based on what you said in the document I mentioned, it looks like you can't assign a new variable to equal a variable that's over VFP's 16 Mb limit. I need to return all of the data in 1 response. Any thoughts on how I can get around this?

Thanks,

Scott

Gravatar is a globally recognized avatar based on your email address. re: Web Connect and VFP String Limit
  Rick Strahl
  Scott R
  Oct 10, 2018 @ 01:47pm

Yes that's problem that doesn't have a good solution. The string based output is limited to 16megs because it's doing other stuff to the response - headers are added after the content for example, which means the string has to be manipulated and that's actually what's breaking things.

For specific requests however you can fake out the pipeline by creating a file based response object like this:

FUNCTION LongString()

this.oResponse = CREATEOBJECT("wwResponseFile",ADDBS(SYS(2023)) + SYS(2015) + ".txt")
Response = this.oResponse

lcString = REPLICATE("1234567890",1500000) && < 16 megs
lcString = lcString + REPLICATE("1234567890",1000000)

Response.Write(lcString)
ENDFUNC
*   LongString

This works.

But there's a caveat - this Response object doesn't have the same features as wwPageResponse that's used by default, so this works only for simple scenarios where sending a single response.

Generally speaking though sending huge responses through web Connection code isn't a good idea. If you have large items like this it's better to dump them to file and then use DownloadFile which lets IIS stream the file down rather than buffering the thing in memory through FoxPro and .NET/ISAPI.

+++ Rick ---

© 1996-2024