From YiPs Wiki (i powered)

XMLService: XMLSERVICE Ruby Don Work

(click to open)

Quick Page Table of Contents

Scanning…

Ruby Toolkit Don …

THIS PAGE IS COMPLETELY OUT OF DATE (WRONG)

do not use

To see how to use XMLService from a non IBMi client click here: non ibmi client.

Access database table data via SQL with XMLService: non ibmi client sql

This page xmlservice examples are out of date, use the following syntax …

Don example is out of date (completely wrong) ...

#   D  INCHARA        S              1a
#   D  INCHARB        S              1a
#   D  INDEC1         S              7p 4        
#   D  INDEC2         S             12p 2
#   D  INDS1          DS                  
#   D   DSCHARA                      1a
#   D   DSCHARB                      1a           
#   D   DSDEC1                       7p 4      
#   D   DSDEC2                      12p 2            
#    *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#    * main(): Control flow
#    *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#   C     *Entry        PLIST                   
#   C                   PARM                    INCHARA
#   C                   PARM                    INCHARB
#   C                   PARM                    INDEC1
#   C                   PARM                    INDEC2
#   C                   PARM                    INDS1

class Test_80010_DSLCallPgmZZCALL < RowColUnitTest
  # -------------------------------
  # test functions (start with prefix test_)
  # rake test -- Unit run alpha sort order
  # run #1) test_0000_connect
  # run #2) test_nnnn_xxx
  # :
  # run #n) test_9999_close
  # -------------------------------
  def test_0030_pgm_zzcall_array
    # call IBM i ZZCALL (default values)
    zzcall = XMLService::I_PGM.new("ZZCALL",$toolkit_test_lib,{'error'=>'fast'})
    zzcall.input_parms do
     char "inchara", 1
     char "incharb", 1
     dec "indec1", 7, 4
     dec "indec2", 12, 2
     struct("inds1", 1) do
       char "dschara", 1
       char "dscharb", 1
       dec "dsdec1", 7, 4
       dec "dsdec2", 12, 2
     end
    end

    # set it Tony way ... PARMn is implied 
    zzcall.input.PARM0.inchara          = 'a'
    zzcall.input.PARM1.incharb          = 'a'
    zzcall.input.PARM2.indec1           = 11.1111
    zzcall.input.PARM3.indec2           = 11.11
    zzcall.input.PARM4.inds1[0].dschara = 'a'
    zzcall.input.PARM4.inds1[1].dscharb = 'a'
    zzcall.input.PARM4.inds1[2].dsdec1  = 111.1111
    zzcall.input.PARM4.inds1[3].dsdec2  = 1111.11
    # puts zzcall.inspect
    puts "\n+++++++++ dump_inspect ++++++++++++++++"
    puts zzcall.dump_inspect
    puts zzcall.to_xml

    # set it Don way ... what is a parm?
    zzcall.input.inchara          = 'b'
    zzcall.input.incharb          = 'b'
    zzcall.input.indec1           = 22.2222
    zzcall.input.indec2           = 22.22
    zzcall.input.inds1[0].dschara = 'b'
    zzcall.input.inds1[1].dscharb = 'b'
    zzcall.input.inds1[2].dsdec1  = 222.2222
    zzcall.input.inds1[3].dsdec2  = 2222.22
    # puts zzcall.inspect
    puts "\n+++++++++ dump_inspect ++++++++++++++++"
    puts zzcall.dump_inspect
    puts zzcall.to_xml

    # call IBM i ZZCALL
    zzcall.execute

    #puts zzcall.inspect
    puts "\n+++++++++ dump_inspect ++++++++++++++++"
    puts zzcall.dump_inspect

    puts "\n+++++++++ output xml ++++++++++++++++"
    puts zzcall.out_xml


    # set it Aaron way ... just pass the data 
    parms = [ {'inchara'=>'1'},
              {'incharb'=>'1'},
              {'indec1'=>11.1111},
              {'indec2'=>111.11},
              {'inds1'=>[{'dschara'=>'2'},{'dscharb'=>'2'},{'dsdec1'=>22.2222},{'dsdec2'=>222.22}]} ]
    zzcall.call(parms)

    puts "\n+++++++++ input xml ++++++++++++++++"
    puts zzcall.to_xml

    #puts zzcall.inspect
    puts "\n+++++++++ dump_inspect ++++++++++++++++"
    puts zzcall.dump_inspect

    puts "\n+++++++++ output xml ++++++++++++++++"
    puts zzcall.out_xml

    # response xml with fewer dots ... clever naming
    puts "\n+++++++++ output fewer ++++++++++++++++"
    puts " inchara...#{zzcall.response.inchara}\n"
    puts " incharb...#{zzcall.response.incharb}\n"
    puts " indec1....#{zzcall.response.indec1}\n"
    puts " indec2....#{zzcall.response.indec2}\n"
    zzcall.response.inds1.each do |inds1|
      puts "  dschara...#{inds1.dschara}"
      puts "  dscharb...#{inds1.dscharb}"
      puts "  dsdec1....#{inds1.dsdec1}"
      puts "  dsdec2....#{inds1.dsdec2}"
    end

  end

end
Retrieved from http://youngiprofessionals.com/wiki/index.php/XMLService/XMLSERVICERubyDonWork
Page last modified on December 02, 2015, at 12:23 PM EST