Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 2 Jahren, 3 Monaten
Letzter Beitrag:
vor 2 Jahren, 3 Monaten
Beteiligte Autoren:
Michael Drechsel, Steven Sitas, DannHCS, Stewart Crisler

[WD20] Best way to pass records/array of records to WebService function?

Startbeitrag von DannHCS am 18.03.2016 14:40

have you a best way to pass a variable of record type or an array of records to a WebService function?

I've already tried to use Serialize/Deserialize, but they don't works with the record variable.



Hi Dann,

you can use UML to create structures or classes from your files or queries.
Then you can use the record variable to fill the structure before "serialize" it.
Backwards you can use "filetoarray" to fill the array of structures or classes from your qery in the webservice.

von Michael Drechsel - am 18.03.2016 15:24
Hi Michael,
thank you very much for your reply.
I'd like to use a global procedure to manage the records of every table in the database.
I prefer to not create a class/structure for every table, I prefer to use a "dynamic variable" (such like the record variable).

von DannHCS - am 18.03.2016 15:58
Hi Dann,

UML runs full automatic. If you find a better way, let me know.
I´m in the middle of recreating my old WD14 program from native HFSQL access to a completly webservice access.
It´s a pain, because every little database access must through the "serialize/deserialize"-process ....

von Michael Drechsel - am 18.03.2016 16:04
I would experiment with the variant. I'm pretty sure it can be serialized/deserialized and it can handle structure like data in an array format. I can't remeber if it can handle an array of record variables.

Stewart Crisler

von Stewart Crisler - am 18.03.2016 19:06
Hi Dann,
here is the type of code I use (NO UML and NO Classes)

ST_sSales is Structure
ontheRoad_GUID is string
OntheRoad_Seq is int

// Same thing for ST_sSalesFinance and ST_sSalesProducts structure //

// this is the structure sent//
// notice nCounter - its just a STUPID DUMMY//
// it won't work if you don't have one !!!//

ST_PostSales is Structure
nCounter is int
arrMySales is array of ST_sSales
arrMySalesFinance is array of ST_sSalesFinance
arrMySalesProducts is array of ST_sSalesProducts

// actual code to send to WEB Service //
nDummyScript is int=0
mySendResult is int
bufPost is Buffer

// fill in the ST_PostSales //

myPostSales is ST_PostSales
myPostSales.nCounter=77 // only ONCE at the beginning

// IN somekind of LOOP / QUERY ?
myPostSales.arrMySales[nDummyScript].ontheRoad_GUID = your data
myPostSales.arrMySales[nDummyScript].OntheRoad_Seq = your data
// END of LOOP

// Same code above for ST_sSalesFinance and ST_sSalesProducts structure

// now serialize and send it ...

Serialize(myPostSales, bufPost, psdJSON)
RESULT mySendResult

// Sales_Import is the procedure on the WEB Service ///

von Steven Sitas - am 19.03.2016 10:25
Hi Steven,

if you don´t use UML, how do you manage database / query fields modification ? (new fields, rename, deletion ?)
Why do you use "psdJSON" and not "binary" (it´s faster because less size) ?

von Michael Drechsel - am 19.03.2016 10:59
Hi Michael,
I think that it is more appropriate - when teaching WD techniques - to use straight procedural code.
If you understand the "underlying procedural code" it is easy - if you like - to go to UML, classes etc.

(1) I use this kind of code in my applications:
ST_OrderLines is Structure
r_OrderLine is Record of OrderLine

So ST_OrderLines and r_OrderLine is always in (some way) inSynch with my database.
I never have to do any kind of UML regenaration etc ...
Except of course when I change/delete field names.
The debugger catches these problems and I fix them

(2) I always like to be at the PHYSICAL LEVEL of my database.
Probably the way my brain was trained all these years :)

(3) I also use BINARY (most of the time) - it is faster.
But I have found situations where a 3rd party couldn't consume it with .NET/Java apps.

Steven Sitas

von Steven Sitas - am 19.03.2016 11:33
Hi Steven,

(1) If I´m not wrong I think the record variable doesn´t work with queries. How do you handle this ?

von Michael Drechsel - am 19.03.2016 12:05
Hi Michael,
I mostly use SQL code for the queries -so I/ or the users construct them on the fly.
The only problem with Records is that they are not directly available in browser code, in WebDev.

Steven Sitas

von Steven Sitas - am 19.03.2016 12:23
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.