This is an example api that RedHat gives for accessing their Satellite:
import java.util.List; import java.util.Map; import java.util.ArrayList; import redstone.xmlrpc.XmlRpcClient; public class Test { public static void main( String[] cmdargs ) throws Exception { XmlRpcClient client = new XmlRpcClient( "http://satellite.example.com/rpc/api", false ); List args = new ArrayList(); args.add("user"); args.add("password"); String auth = (String) client.invoke("auth.login", args); args.clear(); args.add(auth); List<Map> systems = (List<Map>) client.invoke("system.listUserSystems", args); for (Map server : systems) { System.out.println(server.get("name")); } }} I've changed it to this for NetRexx: import java.util.List import java.util.Map import java.util.ArrayList import redstone.xmlrpc.XmlRpcClient class client method main(cmdargs=String[]) public static signals Exception client = XmlRpcClient("http://oursatelliteserver/rpc/api",0) args = ArrayList() args.add("user") args.add("password") auth = String client.invoke("auth.login", args) args.clear() args.add(auth) systems = (args) client.invoke("system.listUserSystems", args) loop server over systems System.out.println(server.get("name")) end The compile is successful: $ nrc client.nrx NetRexx portable processor 3.04 NetRexx '3.04', build 1-20150504-0639 Copyright (c) RexxLA, 2011,2014. All rights reserved. Parts Copyright (c) IBM Corporation, 1995,2008. Program client.nrx === class client === function main(String[]) 7 +++ method main(cmdargs=String[]) public static signals Exception +++ ^^^^^^^^^ +++ Warning: Checked exception 'Exception' is in SIGNALS list but is not signalled within the method signals MalformedURLException,XmlRpcFault Note: /client.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Compilation of 'client.nrx' successful [one warning] Yet when I run, it returns nothing: $ java client $ I believe the problem is in: List<Map> systems = (List<Map>) client.invoke("system.listUserSystems", args); that I've converted to: systems = (args) client.invoke("system.listUserSystems", args) |
Suggestion:
---------------------------------------------------------------------------------------------------------------------- import java.util.List import java.util.Map import java.util.ArrayList import redstone.xmlrpc.XmlRpcClient class client method main(cmdargs=String[]) public static signals Exception trace results client = XmlRpcClient("http://oursatelliteserver/rpc/api",0) args = ArrayList() args.add("user") args.add("password") auth = String client.invoke("auth.login", args) args.clear() args.add(auth) systems = List client.invoke("system.listUserSystems", args) server=Map loop server over systems System.out.println(server.get("name")) end ---------------------------------------------------------------------------------------------------------------------- On 5/18/2015 10:52 AM, gpatrick wrote: > This is an example api that RedHat gives for accessing their Satellite: > import java.util.List; > import java.util.Map; > import java.util.ArrayList; > import redstone.xmlrpc.XmlRpcClient; > public class Test { > public static void main( String[] cmdargs ) throws Exception { > XmlRpcClient client = new XmlRpcClient( > "http://satellite.example.com/rpc/api", false ); > List args = new ArrayList(); > args.add("user"); > args.add("password"); > String auth = (String) client.invoke("auth.login", args); > args.clear(); > args.add(auth); > List<Map> systems = (List<Map>) client.invoke("system.listUserSystems", > args); > for (Map server : systems) { > System.out.println(server.get("name")); > } > }} > > I've changed it to this for NetRexx: > import java.util.List > import java.util.Map > import java.util.ArrayList > import redstone.xmlrpc.XmlRpcClient > > class client > method main(cmdargs=String[]) public static signals Exception > client = XmlRpcClient("http://oursatelliteserver/rpc/api",0) > args = ArrayList() > args.add("user") > args.add("password") > > auth = String client.invoke("auth.login", args) > args.clear() > args.add(auth) > systems = (args) client.invoke("system.listUserSystems", args) > > loop server over systems > System.out.println(server.get("name")) > end > > The compile is successful: > $ nrc client.nrx > NetRexx portable processor 3.04 NetRexx '3.04', build 1-20150504-0639 > Copyright (c) RexxLA, 2011,2014. All rights reserved. > Parts Copyright (c) IBM Corporation, 1995,2008. > Program client.nrx > === class client === > function main(String[]) > 7 +++ method main(cmdargs=String[]) public static signals Exception > +++ ^^^^^^^^^ > +++ Warning: Checked exception 'Exception' is in SIGNALS list but is not > signalled within the method > signals MalformedURLException,XmlRpcFault > Note: /client.java uses unchecked or unsafe operations. > Note: Recompile with -Xlint:unchecked for details. > Compilation of 'client.nrx' successful [one warning] > > > Yet when I run, it returns nothing: > $ java client > $ > > I believe the problem is in: > List<Map> systems = (List<Map>) client.invoke("system.listUserSystems", > args); > that I've converted to: > systems = (args) client.invoke("system.listUserSystems", args) > > > > > > -- > View this message in context: http://ibm-netrexx.215625.n3.nabble.com/Java-RedHat-api-tp4027430.html > Sent from the ibm-netrexx mailing list archive at Nabble.com. > > _______________________________________________ > Ibm-netrexx mailing list > [hidden email] > Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ > > > _______________________________________________ Ibm-netrexx mailing list [hidden email] Online Archive : http://ibm-netrexx.215625.n3.nabble.com/ |
Free forum by Nabble | Edit this page |