Hi Mark, for a view month i was trying to understand xmlrpc an write a client to an exisiting xml-rpc server.
My first success after a view tests at home, was my jsp-page that connect to wordtracker.com , so i was sure, that i had install the xmlrpc-lib correctly--> <%@ page import="java.net.*"%> <%@ page import="java.util.*"%> <%@ page import="org.apache.xmlrpc.client.*"%> <%@ page import="org.apache.xmlrpc.client.XmlRpcClientConfigImpl.*"%> <%@ page import="org.apache.xmlrpc.XmlRpcException"%> <% String address = "http://test.xmlrpc.wordtracker.com/"; String message= "testmessage"; XmlRpcClientConfigImpl rpcconfig = new XmlRpcClientConfigImpl(); rpcconfig.setServerURL(new URL(address)); XmlRpcClient client = new XmlRpcClient(); client.setConfig(rpcconfig); Vector params = new Vector (); params.addElement( "guest" ); String methodName = "ping"; try { // client.execute(methodName, params); Object result=client.execute(methodName, params); if (result instanceof Boolean) { Boolean b=(Boolean)result; System.out.println (result.toString()); } /*for (int i=0; i < result.size(); i++) { System.out.println (result.elementAt(i)); }*/ } catch (XmlRpcException e) { //XmlRpcException ex =(XmlRpcException)e; System.err.println ("client.excecute failed - " +e.toString()); message=e.toString()+" "+ e.getMessage()+ "Code="+e.code; } catch(Exception ex) { message += ex.getMessage(); } %> <html> <body bgcolor="white"> <font size=4> <br> <%= message%> </font> </body> </html> <---- Next Problem for me to solve was the factor that i need the right proxy-settings to come through the firewall in my office--> Properties systemSettings = System.getProperties(); systemSettings.put("http.proxyHost","0.0.0.0") ; systemSettings.put("http.proxyPort", "8080") ; After that everything was very quick and easy and just basic java. Here are some examples --> Vector params = new Vector (); HashMap login=new HashMap(2); login.put("username","rote"); login.put("password","zora"); String methodName = "isAlive"; try { // isAlive? Object result=client.execute(methodName, params); if (result instanceof Boolean) { Boolean b=(Boolean)result; System.out.println (result.toString()); } methodName="getPools"; params.clear(); params.addElement(login); int mandant=3333; params.addElement(mandant); Object opool=client.execute(methodName, params); if (opool instanceof HashMap) { HashMap pool = (HashMap)opool; Iterator ipool=pool.keySet().iterator(); while(ipool.hasNext()) { Object o=ipool.next(); System.out.println (o.toString()); System.out.println (pool.get(o.toString())); } } } //doProfileUpdate methodName="doProfileUpdate"; int poolid=11111111; // int profilid=0; //0 fuer neu int profilid=14040346; //intnr test int permission=3; HashMap attributes= new HashMap(); attributes.put("INTNR","99999"); attributes.put("SALUTATION","1"); attributes.put("FIRSTNAME","Anthrazit"); attributes.put("NAME","Becker"); attributes.put("EMAIL","anthra...@web.de); attributes.put("COMPANY","TEST FIRMA"); attributes.put("ADDRESS","mystreet"); attributes.put("STREETNUMBER","46"); attributes.put("CITY","myCity"); attributes.put("ZIPCODE","02222"); attributes.put("PHONEPREFIX","000"); attributes.put("PHONENUMBER","1565432"); ArrayList lstTestzielg = new ArrayList(2); int tsec=61204; int tvir=61208; lstTestzielg.add( tsec ); lstTestzielg.add( tvir ); attributes.put("zielg",lstTestzielg ); params.clear(); params.addElement(login); params.addElement(poolid); params.addElement(profilid); params.addElement(attributes); params.addElement(permission); Object oprofiles=client.execute(methodName, params); if (oprofiles instanceof HashMap) { HashMap profiles = (HashMap)oprofiles; Iterator ipool=profiles.keySet().iterator(); while(ipool.hasNext()) { Object o=ipool.next(); System.out.println (o.toString()); System.out.println (profiles.get(o.toString())); } } } catch (XmlRpcException e) { //XmlRpcException ex =(XmlRpcException)e; System.err.println ("client.excecute failed - " +e.toString()); } catch(Exception ex) { error = ex.toString()+" "+ex.getMessage(); } ------------ I hope that will help you! Bye Anthrazit -----Ursprüngliche Nachricht----- Von: "Mark Wood-Patrick" <mwoodpatr...@nvidia.com> Gesendet: 30.09.2010 16:36:27 An: "'xmlrpc-dev@ws.apache.org'" <xmlrpc-dev@ws.apache.org> Betreff: Need more examples >I have been reading the docs but it seems like I need more examples. I'm >trying to create a client side JAVA API to an existing XML-RPC based web >service. The examples I have seen in the docs so far are sending/receiving >simple scalar values but the values in the web service I'm working with have >complex objects which can have many fields which can be enums or references to >other objects. Is there some further examples, downloadable code that I could >look at to figure out the best way to do this. > >BTW there is an existing c# interface to the web service that uses >CookComputing.XmlRpc so an example of the kind of objects I'm talking about is >shown below: > >public enum TaskStatusEnum > { > TASK_STATUS_NEVER_ASSIGNED = 0, > TASK_STATUS_REASSIGNED = 1, > TASK_STATUS_RESTARTED = 2, > TASK_STATUS_ASSIGNING_RESOURCES = 100, > TASK_STATUS_RESOURCES_ALLOCATING = 100, > TASK_STATUS_TESTER_ASSIGNED = 100, > TASK_STATUS_RESOURCES_ASSIGNED = 200, > > TASK_STATUS_ERROR = 700, > TASK_STATUS_DISABLED = 900, > } > >public struct TaskExecution > { > public Int32 Id; > public Int32 TaskId; > public Int32 ResourcesAssignmentId; > public int LastStatus; > public Int32 ReturnCode; > public Datetime DateStarted; > public Datetime DateFinished; > public OutputType[] RunInformation; > } > >[XmlRpcMethod("GetCurrentTaskExecutions")] > TaskExecution[] GetCurrentTaskExecutions(Int32[] TaskId); > >I'm unclear as to how I would implement this using Apache XML-RPC any pointers >would be much appreciated > >Mark Wood-Patrick > > >----------------------------------------------------------------------------------- >This email message is for the sole use of the intended recipient(s) and may >contain >confidential information. Any unauthorized review, use, disclosure or >distribution >is prohibited. If you are not the intended recipient, please contact the >sender by >reply email and destroy all copies of the original message. >----------------------------------------------------------------------------------- ___________________________________________________________ WEB.DE DSL Doppel-Flat ab 19,99 €/mtl.! Jetzt auch mit gratis Notebook-Flat! http://produkte.web.de/go/DSL_Doppel_Flatrate/2