SAX and temp-table

kirsch59

Member
I’m running WebSpeed 10.1C on Window Server 2008.
I’m using SAX to create the XML when making a request to a webservice. When I successfully login to the webservice it returns a token that should be included on all subsequent transactions. I’m storing the login token data elements in a temp-table.
How do I take the contents of the temp-table and output it using SAX ? The temp-table field names and xml-node-names match the login token.
 

kirsch59

Member
Let me try and explain it. After I connect to a webservice I do a login request. The response from the login method is a token that I must use on all subsequent webservice calls. I store the login token in a temp-table. I'm using the SAX writer to create the XML for all web service calls.

Instead of hard coding the WRITE-DATA-ELEMENT ("Id", tt-login.Id), the "Id" can I use the temp-table field names (tt-login.Id) or xml-node-names;
 

Stefan

Well-Known Member
Something like this?

Code:
DEFINE TEMP-TABLE tt-login
   FIELD Id AS CHAR.

DEF VAR hsax   AS HANDLE   NO-UNDO.
DEF VAR ii     AS INT      NO-UNDO.
DEF VAR hb     AS HANDLE   NO-UNDO.
DEF VAR hf     AS HANDLE   NO-UNDO.

hb = TEMP-TABLE tt-login:DEFAULT-BUFFER-HANDLE.

DO  ii = 1 TO hb:NUM-FIELDS:

   hf = hb:BUFFER-FIELD( ii ).

   CASE hf:XML-NODE-TYPE:
      WHEN "attribute"  THEN hsax:INSERT-ATTRIBUTE( hf:NAME, hf:STRING-VALUE ).
      WHEN "element"    THEN hsax:WRITE-DATA-ELEMENT( hf:NAME, hf:STRING-VALUE ).
      OTHERWISE MESSAGE "oops" hf:XML-NODE-TYPE.
   END CASE.

END.
 
Top