Connection

XMLService.Connection History

Hide minor edits - Show changes to output

Deleted lines 34-45:

'''Alternative ...'''\\
You may also use alternative REST connection with xmlservice when you have no ibm_db connection available.
[@
irb
2.0.0p247 :001 > require 'xmlservice'
2.0.0p247 :002 > ActiveXMLService::Base.establish_connection connection: "http://myibmi/cgi-bin/xmlcgi.pgm",database: '*LOCAL', username: 'USER400',password: 'secret'
2.0.0p247 :003 > cmd = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'")
2.0.0p247 :007 > cmd.xmlservice
2.0.0p247 :008 > cmd.out_xml
@]

Changed line 36 from:
'''Alternative ...'''
to:
'''Alternative ...'''\\
Changed lines 26-31 from:
/YOUR_RAILS_APP> '''rails console'''\\
irb(main):001:0>  '''require 'xmlservice' '''\\
irb(main):001:0>  '''ActiveXMLService::Base.establish_connection connection: 'ActiveRecord' '''\\
irb
(main):001:0>  '''cmd = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'") '''\\
irb(main):001:0>  '''cmd.xmlservice '''\\
irb(main):001:0>  '''puts cmd.out_xml
'''\\
to:
[@
/YOUR_RAILS_APP> rails console
irb(main):001:0>  require 'xmlservice'
irb(main):001:0>  ActiveXMLService::Base.establish_connection connection: 'ActiveRecord'
irb(main):001:0>  cmd = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'")
irb(main):001:0>
  cmd.xmlservice
irb
(main):001:0>  puts cmd.out_xml
@]


'''Alternative ...
'''
You may also use alternative REST connection with xmlservice when you have no ibm_db connection available.
[@
irb
2.0.0p247 :001 > require
'xmlservice'
2.0.0p247 :002 > ActiveXMLService::Base.establish_connection connection: "http://myibmi/cgi-bin/xmlcgi.pgm",database: '*LOCAL', username: 'USER400',password: 'secret'
2.0.0p247 :003 > cmd = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'")
2.0.0p247 :007 > cmd.xmlservice
2.0.0p247 :008 > cmd.out_xml
@]

Changed line 3 from:
!!! Ruby Toolkit Don ...
to:
!!! Ruby Toolkit Don: Establishing a Connection
Changed lines 7-9 from:
XMLService requires a connection. The connection method can:
# accept parameters that provide detailed options,
# or you can simply tell it to use your existing
database.yml configuration for the ibm_db ActiveRecord adapter.
to:
XMLService requires a connection. The connection method parameters can contain:
# all detailed options
# simply reference your existing Rails
database.yml configuration for the ibm_db ActiveRecord adapter.
Added line 4:
[[XMLSERVICERubyDonWork]]
Deleted line 31:
Added lines 1-31:
(:quicktoc:)
>>round frame bgcolor=#ffffdd<<
!!! Ruby Toolkit Don ...
>><<

XMLService requires a connection. The connection method can:
# accept parameters that provide detailed options,
# or you can simply tell it to use your existing database.yml configuration for the ibm_db ActiveRecord adapter.
 
The following ruby code, for example, creates a connection to the current IBMi and then prints the output from the QTIME system value on the shell console:

[@
require 'xmlservice'
ActiveXMLService::Base.establish_connection(
  connection: 'ActiveRecord', adapter: 'ibm_db', database: '*LOCAL',
  username: 'USER400', password: 'secret'
)
wrksysval = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'")
wrksysval.xmlservice
puts wrksysval.out_xml
@]

But, if you are in the context of a Rails application that has an ibm_db adapter already configured in database.yml, the establish connection method need only be passed the connection adapter type of ActiveRecord. The following shows how to run the WRKSYSVAL command from a Rails console:

/YOUR_RAILS_APP> '''rails console'''\\
irb(main):001:0>  '''require 'xmlservice' '''\\
irb(main):001:0>  '''ActiveXMLService::Base.establish_connection connection: 'ActiveRecord' '''\\
irb(main):001:0>  '''cmd = XMLService::I_SH.new("system -i 'WRKSYSVAL SYSVAL(QTIME) OUTPUT(*PRINT)'") '''\\
irb(main):001:0>  '''cmd.xmlservice '''\\
irb(main):001:0>  '''puts cmd.out_xml '''\\