Quantcast

Bugzilla Webservice API -> Named argument problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Bugzilla Webservice API -> Named argument problem

Jethro Borsje-2
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
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=lists@...>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bugzilla Webservice API -> Named argument problem

Max Kanat-Alexander
On Thu, 13 Nov 2008 15:03:43 +0100 "Jethro Borsje"
<[hidden email]> wrote:
> List<String> loginList = new ArrayList<String>();

        You should be passing a Map, not an ArrayList. In XML-RPC
terms, all Bugzilla parameters are a <struct>.

        -Max
--
http://www.everythingsolved.com/
Competent, Friendly Bugzilla and Perl Services. Everything Else, too.
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=lists@...>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bugzilla Webservice API -> Named argument problem

Jethro Borsje-2
Dear Max,

Thank you for your reply.

>> List<String> loginList = new ArrayList<String>();
>
>        You should be passing a Map, not an ArrayList. In XML-RPC
> terms, all Bugzilla parameters are a <struct>.
>
I was aware of that, but the XMLRpcClient of Apache only lets me pass
a List or an Array to the execute() method. However, I just found out
the following syntax does the trick:
[code]Object loginResult = rpcClient.execute("User.login", new
Object[]{loginMap});[/code]

So everything works fine now.

Best regards,
Jethro
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=lists@...>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bugzilla Webservice API -> Named argument problem

chandu-4
In reply to this post by Jethro Borsje-2
On Nov 13, 7:03 pm, "Jethro Borsje" <[hidden email]> wrote:

> 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
> -
> To view or change your list settings, click here:
> <http://bugzilla.org/cgi-bin/mj_wwwusr?user=dev-apps-bugzi...@...>

> Hi
>
> I  am trying to Integrate bugzilla but I am not able to get any Web
> Services or WSDl related to that I was hoping if you can provide me
> the WSDL or some link from where I can find this Web Services or WSDL.
>
> Any help will be great.

Vivek Manchanda
_______________________________________________
dev-apps-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-apps-bugzilla
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=lists@...>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bugzilla Webservice API -> Named argument problem

Max Kanat-Alexander
On Thu, 20 Nov 2008 05:56:04 -0800 (PST) chandu
<[hidden email]> wrote:
> > I  am trying to Integrate bugzilla but I am not able to get any Web
> > Services or WSDl related to that I was hoping if you can provide me
> > the WSDL or some link from where I can find this Web Services or
> > WSDL.

        This question would be more appropriate for the
support-bugzilla mailing list, described here:

        http://www.bugzilla.org/support/

         Also, you wrote it like it was a reply, which was very
confusing. Start your own threads on mailing lists when you have
questions.

        -Max
--
http://www.everythingsolved.com/
Competent, Friendly Bugzilla and Perl Services. Everything Else, too.
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=lists@...>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Bugzilla Webservice API -> Named argument problem

DaniloCoppi
Here is an working code of webservice-java login:

Used Libraries:
Apache xmlrpc lib 3.1.3

XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setEnabledForExtensions(true);
config.setServerURL(new URL("http://myServerName/bugzilla/xmlrpc.cgi"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);

Map<String , String> map = new HashMap<String, String>();
map.put("login", "danilo.coppi@gmail.com");
map.put("password", "mYpAsSwOrD");

Object result = client.execute("User.login", new Object[]{map});
System.out.println(result);
Loading...