Web API - XPRIM_RandomAccessJsonReader - Size Limit?

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Post by Joerg Hamacher »

Hi,

I use XPRIM_RandomAccessJsonReader for working with HTTP request responses.

Definition: Define_Com Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
Receiving the HTTP response: #Reader.SetSourceString String(#HTTP_Request.Response.AsString) Errorinfo(#ErrorInfo)

I have to work with responses that are quite large - CurSizes of #HTTP_Request.Response.AsString can be more than 200000.
I have the feeling that the Reader cannot save so many characters. Is this correct? Is there a limit to 65555?

When I receive requests that are of CurSize = 40000 e.g. the commands
#STD_NUM := #Reader.ReadNumberWithName( "total" )
#Reader.BeginArrayWithName( "data" )
#Reader.BeginObjectAtIndex( 1 )
#STD_TEXT := #Reader.ReadStringWithName( "orderNumber" ).AsNativeString
#STD_TEXTL := #Reader.ReadStringWithName( "currencyId" ).AsNativeString


retrieve the correct values that I can see in my response.body.log file.

When CurSize is much bigger these commands retrieve no values at all (I suppose because the end of the array structure and other values are not integrated in the string that the reader contains).

How do you handle big amounts of response data in your web APIs?

Kind regards,
Joerg
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Post by BrendanB »

Joerg,

please review:

viewtopic.php?f=4&t=2047

which talks about using #Prim_JsonReader

this works quite well for *Large* data sets.. (there is an example in the last post of it..)

Brendan.
Speedlime
Posts: 44
Joined: Wed Feb 03, 2021 2:52 am

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Post by Speedlime »

Has anyone got a working example of using #XPRIM_RandomAccessJsonReader, I followed the simple examples in manual but I am not sure if it is the size of the Json returned that is the issue, or if it my code. The Json is only 6.56 KB using V15 150040 epc

DEFINE_COM Class(#XPRIM_RandomAccessJsonReader) Name(#Reader)
IF (#Request.Response.IsSuccessfulRequest)
IF (#Request.Response.IsSuccessHttpStatusCode)

#Reader.SetSourceHttpResponse Httpresponse(#Request.Response)

#Reader.BeginObjectWithPath( 'consignment' )
* fields are type string
#LMCNCOD := #Reader.ReadStringWithName( 'consignmentCode' ).AsNativeString
#LMCNSTS := #Reader.ReadStringWithName( 'status' ).AsNativeString
#LMCCCOD := #Reader.ReadStringWithName( 'carrierConsignmentCode' ).AsNativeString
#Reader.EndObject

#Reader.BeginObjectWithPath( 'consignment/paperwork' )
* fields are blobs
#LMCNLBL := #Reader.ReadStringWithName( 'labels' ).AsNativeString
#LMCNCDS := #Reader.ReadStringWithName( 'customs' ).AsNativeString
#Reader.EndObject

Endif
Endif

Any help will be greatly appreciated
Speedlime
Posts: 44
Joined: Wed Feb 03, 2021 2:52 am

Re: Web API - XPRIM_RandomAccessJsonReader - Size Limit?

Post by Speedlime »

Turns out the payload was empty on the return, so the coding is correct.

API logging as specified in the June 2022 Technical Newsletter works well. (attached)
In the logging data you can see the request and response bodies. Great help when developing and testing.

Important entries to add to the Header

* Additional Header Entries
#Request.Content.ContentInfo.MediaType := 'application/json'
#Request.Options.AddHeader Name('Accept') Value('application/json')


The top one tell the server you are sending and talking Json and the second instructs the server being called you want Json returned.
Attachments
LANSA Technical Newsletter June 2022.pdf
(842.43 KiB) Downloaded 1453 times
Post Reply