Newbie to web services - how to load indeterminate longchar array

LarryD

Active Member
OE10.2B Linux

I'm working on my first project using web services (in this case a phone app with Sprint called Telenav) and my first encountering of indeterminate arrays.

I've gotten the code from the wsdl, and can successfully send and receive xml from the web service as long as it's not an indeterminate array.

However, I'm finding I don't know how to deal with/pricess the indeterminate longchar array when it's returned. I can't find any examples where this is done using the ABL either on Progress web site or in the samples documentation for web services.

Here is the code generated by the wsdl:

Code:
DEFINE VARIABLE wsAdmin AS LONGCHAR NO-UNDO.
DEFINE VARIABLE jobId AS INT64 NO-UNDO.
DEFINE VARIABLE getJobEventsReturn AS LONGCHAR EXTENT NO-UNDO.


FUNCTION getJobEvents RETURNS LONGCHAR EXTENT
  (INPUT wsAdmin AS LONGCHAR,
   INPUT jobId AS INT64)
  IN hTrack_PortType.


/* Function invocation of getJobEvents operation. */
getJobEventsReturn = getJobEvents(wsAdmin, jobId).
All well and good there. Sending the getJobEvents is not a problem.

But no matter what I seem to try with the getJobEventsReturn, I get errors.

Does anyone have a simple example to show how to load the indeterminate longchar array return value into an XML document?

Thanks for any help, pointers et al!
 
Obviously not something people have used much....

Well, after much unsuccessful mucking around with code for the past week (which is why I was at the point of giving up and so posted this earlier), I finally just figured it out.

I knew that I needed to be able to make the indeterminate array one with a fixed size via the extent function. However, turns out you can't do that in the same .p code block, and you have to pass it as a parameter then fix the extent in the sub procedure. Seems rather convoluted but at least it now works as I need it to.

e.g.
Code:
DEFINE VARIABLE wsAdmin AS LONGCHAR NO-UNDO.
DEFINE VARIABLE jobId AS INT64 NO-UNDO.
DEFINE VARIABLE getJobEventsReturn AS LONGCHAR EXTENT NO-UNDO.


FUNCTION getJobEvents RETURNS LONGCHAR EXTENT
  (INPUT wsAdmin AS LONGCHAR,
   INPUT jobId AS INT64)
  IN hTrack_PortType.


/* Function invocation of getJobEvents operation. */
getJobEventsReturn = getJobEvents(wsAdmin, jobId).

run my_ip ( getJobEventsReturn ).

...

PROCEDURE my_ip.

def input parameter my_array as longchar extent no-undo.

def var num_elements as int no-undo.

num_elements = EXTENT( my_array ). /* this sets the array to determinate fixed size */

... other stuff ...

END PROCEDURE.
 
Code:
DEFINE VARIABLE wsAdmin AS LONGCHAR NO-UNDO.
DEFINE VARIABLE jobId AS INT64 NO-UNDO.
DEFINE VARIABLE getJobEventsReturn AS LONGCHAR EXTENT NO-UNDO.
RUN getJobEvents IN hTrack_PortType (wsAdmin, jobId, OUTPUT getJobEventsReturn).
    DEFINE VARIABLE i AS INTEGER NO-UNDO.
    DEFINE VARIABLE hMyInvoice AS HANDLE NO-UNDO.

    DO i = 1 TO EXTENT(getJobEventsReturn):
      IF LENGTH(TRIM(getJobEventsReturn[i])) = 0 THEN LEAVE.
      CREATE X-DOCUMENT hMyInvoice.
      hMyInvoice:LOAD("LONGCHAR",getJobEventsReturn[i],FALSE).
      hMyInvoice:SAVE("file", STRING(i) + "Invoice.xml").
      DELETE OBJECT hMyInvoice.
    END.
 
Back
Top