Bugzilla Webservice API -> Named argument problem

Jethro Borsje jethroborsje at gmail.com
Thu Nov 13 14:03:43 UTC 2008


Hello everybody,

I am trying to let my Java application connect to Bugzilla (v3.0.6)
via the Webservice API. I am using xmlrpc-3.1 from apache, and I am
trying to make it work as a small test case program. In order to login
to Bugzilla I try the following:
[code]
// Initialize everything.
HttpClient httpClient = new HttpClient();
XmlRpcClient rpcClient = new XmlRpcClient();
XmlRpcCommonsTransportFactory factory = new
XmlRpcCommonsTransportFactory(rpcClient);
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
factory.setHttpClient(httpClient);
rpcClient.setTransportFactory(factory);
try
{
   config.setServerURL(new URL("http://cia/bugzilla/xmlrpc.cgi"));
}
catch (MalformedURLException ex)
{
   ex.printStackTrace();
   System.exit(-1);
}
rpcClient.setConfig(config);

List<String> loginList = new ArrayList<String>();
loginList.add("login");
loginList.add("<username>@<domain>.com");
loginList.add("password");
loginList.add("<password>");
loginList.add("rememberlogin");
loginList.add("Bugzilla_remember");

// login to bugzilla
Object loginResult = rpcClient.execute("User.login", loginList);
System.out.println(loginResult);
[/code]

This results in the following error from Bugzilla:
[error]
Exception in thread "main" org.apache.xmlrpc.XmlRpcException: Can't
use string ("login") as a HASH ref while "strict refs" in use at
Bugzilla/WebService/User.pm line 39.
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:186)
	at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:145)
	at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:94)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:53)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:166)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:157)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:146)
	at bugzilla.BugzillaAutoCreate.main(BugzillaAutoCreate.java:70)
[/error]

I read that I have to use "named arguments", but I am not sure how to
do this. Can somebody please explain to me how to create the proper
argument for the rpcClient.execute("User.login", <argument>);?

-- 
Best regards,
Jethro Borsje

http://www.jborsje.nl



More information about the developers mailing list