Submitted by Anonymous (not verified) on Mon, 07/16/2012 - 00:00
Forums

Is there a way to use another name than the 10 char field names in external described files when you create complex types in a SOAP service?

Niels Liisberg

Mon, 07/16/2012 - 00:00

Yes; You can supply the IceBreak only keyword: COLHDG. This has to be on the likeds line. This will build the complex type element names based on the column heading from the database table. You have to be careful that the column heading needs to conform to a proper wsdl name.

Like this sample:

<%@ language="SQLRPGLE" pgmtype="webservice"%>
<%
h nomain debug
d Product       E DS                  based(prototype_only) qualified
/* -----------------------------------------------------------------------------------
   Get products for producst in the input list
   ----------------------------------------------------------------------------------- */
p getProduct... 
p                 b                   export
d                 pi
d   inArr                             input likeds(Product) dim(10) colhdg
d   outArr                            output likeds(Product) dim(10) colhdg

d* Internal work fields
d   rows                        10i 0 output 
d   i             s             10i 0  
d   prodRec       ds                  likeds(Product)

/free
  // How many was sent to me in the input? 
  rows =  soap_ArrayElements(%addr(inarr));
  for i = 1 to rows;
    // Get a row for each
    prodRec.prodKey = inArr(i).prodKey;
    exec sql
      select *
      into   :prodRec
      from   product
      where  prodKey = :prodRec.prodKey;     
    outArr(i) = prodRec;
  endFor; 

  // This is how many we want to send back to the client
  soap_ArrayElements(%addr(outArr):  rows); 

  return;
/end-free
p                 e

Best regards,
Niels Liisberg