java - XML-RPC giving error while extracting ticket info from Trac -



java - XML-RPC giving error while extracting ticket info from Trac -

i using xml-rpc plugin in java extract ticket info trac.

so far successful next code

config.setbasicusername ("username"); config.setbasicpassword ("password"); config.setserverurl (new url ("trac_url")); client = new xmlrpcclient(); client.setconfig (config); object [] params = new object [] {}; object [] queryresult = null; seek { queryresult = (object []) client.execute ("ticket.query", params); } grab (xmlrpcexception e) { system.out.println(e.getmessage()); system.out.println(e.code); system.out.println(e.linkedexception); system.out.println(e.getcause()); e.printstacktrace(); }

but when alter url project gives error messages

for info url running fine when utilize same url open in browser, can see tickets there, not work in program

i above code

????????? xml_rpc ??????? // system.out.println(e.getmessage()); 1 // system.out.println(e.code); org.apache.xmlrpc.xmlrpcexception: ????????? xml_rpc ??????? @ org.apache.xmlrpc.client.xmlrpcstreamtransport.readresponse(xmlrpcstreamtransport.java:197) @ org.apache.xmlrpc.client.xmlrpcstreamtransport.sendrequest(xmlrpcstreamtransport.java:156) @ org.apache.xmlrpc.client.xmlrpchttptransport.sendrequest(xmlrpchttptransport.java:143) @ org.apache.xmlrpc.client.xmlrpcsunhttptransport.sendrequest(xmlrpcsunhttptransport.java:69) @ org.apache.xmlrpc.client.xmlrpcclientworker.execute(xmlrpcclientworker.java:56) @ org.apache.xmlrpc.client.xmlrpcclient.execute(xmlrpcclient.java:167) @ org.apache.xmlrpc.client.xmlrpcclient.execute(xmlrpcclient.java:137) @ org.apache.xmlrpc.client.xmlrpcclient.execute(xmlrpcclient.java:126) @ xmlropx.listtracticket.extractdatafromtrac(listtracticket.java:206) @ xmlropx.listtracticket.main(listtracticket.java:263) null // system.out.println(e.linkedexception); null // system.out.println(e.getcause());

please help me solve

seems have specific configuration on trac server (e.g. apache httpd) regarding sec url. may seek alternative approach reach out url. maybe produce more detailed exception or else.

i tried work trac on regular 'url' / 'urlconnection' java classes, works ok , command whole process since http/rpc stuff low-level implemented.

the tricky thing ticket version timestamp - should specified additional argument rpc ticket modification method.

a short example.

public static jsonobject sendjsonrpc(string method, jsonarray parameters) throws ioexception, jsonexception { jsonobject rpc = new jsonobject(); rpc.put("method", method); rpc.put("params", parameters); rpc.put("id", jsonidsequence++); string tracurl = configuration.gettracapiurl(); string tracusername = configuration.gettracapiusername(); string tracpassword = configuration.gettracapipassword(); url url = new url(tracurl); urlconnection conn = url.openconnection(); string userpass = tracusername + ":" + tracpassword; string basicauth = "basic " + new string(new base64().encode(userpass.getbytes())); conn.setrequestproperty ("authorization", basicauth); conn.setrequestproperty ("content-type", "application/json"); conn.setdooutput(true); outputstreamwriter wr = new outputstreamwriter(conn.getoutputstream()); logger.debug("jsonrpc request:\n" + rpc.tostring()); wr.write(rpc.tostring()); wr.flush(); wr.close(); bufferedreader rd = new bufferedreader(new inputstreamreader(conn.getinputstream())); string line; string jsontext = ""; while ((line = rd.readline()) != null) { jsontext += line; } rd.close(); logger.debug("jsonrpc response:\n" + jsontext); homecoming new jsonobject(jsontext); }

you can find more examples here java, trac, rpc , json .

java xml-rpc trac

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

html - Submenu setup with jquery and effect 'fold' -

ruby on rails - Devise Logout Error in RoR -