当前位置: 首页 > 工具软件 > Tactic > 使用案例 >

xmlrpc java实现_TACTIC XMLRPC接口分析与Java访问实现

解明辉
2023-12-01

结合TACTIC的API的使用与 `XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); config.setServerURL(new URL("http://192.168.1.107/tactic/default/Api"));

XmlRpcClient client = new XmlRpcClient();

client.setConfig(config);

// 设置传输工厂类

client.setTransportFactory(new XmlRpcSunHttpTransportFactory(client));

// 创建远程方法的参数数组,通过指定远程方法名称进行调用

//get_ticket

String username = "admin";

String password = "yanfa";

Object [] login = new Object[] {username,password};

Object ticket = client.execute("get_ticket", login);

System.out.println(ticket);

String project_code = "sthpw";

String search_type = "sthpw/project";

//This is TACTIC Python Client Model: return python dict

String Python_TICKET = project_code + ":" + ticket;

Object[] params = new Object[]{Python_TICKET,search_type};

Object python_result = client.execute("query", params);

System.out.println(python_result);

//This is TACTIC Javascript Client Model:

Map Javascript_TICKET = new HashMap();

Javascript_TICKET.put("ticket", (String) ticket);

Javascript_TICKET.put("project", "sthpw");

Javascript_TICKET.put("language","javascript");

Map Javascript_Params = new HashMap();

Javascript_Params.put("search_type",search_type);

params = new Object[]{Javascript_TICKET,Javascript_Params};

Object java_result = client.execute("query", params);

System.out.println(java_result);

//java_result is json`

 类似资料: