You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlrpc-dev@ws.apache.org by Helder Ribeiro <he...@gmail.com> on 2008/07/02 15:03:23 UTC

Problem with login using xml-rpc api

Gentlemen,

Im trying to create a bug in a local bugzilla installation using the
bugzilla xml-rpc api but I have a problem with login.

When I call the services that dont require login (get products or legal
values, for example), its working fine. But when I try to create a bug, I
get the following exception:

org.apache.xmlrpc.XmlRpcException: Login Required
    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.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:44)
    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)

I tried to run the login before calling the create but. The login works
fine, it returns the logged user id, but when I call the create I got the
same error.
I tried to put the username and login in the URL but again I got the same
error.

Im using the following code to create the config:

            XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
            config.setServerURL(new URL("
http://localhost/bugzilla/xmlrpc.cgi"));
            config.setBasicUserName("myusername");
            config.setBasicPassword("mypassword");

and the following code to call the service:

XmlRpcClient xmlRpcClient = new XmlRpcClient();
xmlRpcClient.setConfig(config);
Map<Object, Object> result = (Map<Object,
Object>)xmlRpcClient.execute("Bug.create", params);

Did anyone have the same problem before or have an idea of what should I do
?

Thanks in advance,

-- 

Helder Ribeiro

Re: Problem with login using xml-rpc api

Posted by Helder Ribeiro <he...@gmail.com>.
Hi Jochen,

I changed my code to use XmlRpcCommonsHttpTransport to handle cookies and
its working fine.

Thanks a lot.

On Wed, Jul 2, 2008 at 6:17 AM, Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Wed, Jul 2, 2008 at 3:15 PM, Helder Ribeiro <he...@gmail.com> wrote:
> > This is the api documentation:
> >
> > http://www.bugzilla.org/docs/3.0/html/api/Bugzilla/WebService/User.html
> >
> > It says "
> > *Returns*
> >
> > On success, a hash containing one item, id, the numeric id of the user
> that
> > was logged in. A set of http cookies is also sent with the response.
> These
> > cookies must be sent along with any future requests to the webservice,
> for
> > the duration of the session.
> > "
> > but when I run the execute method in the client for the "Bug.login"
> method
> > it returns a Map with only one property, the user id.
>
> See the section on "Cookie handling" on
>
>    http://ws.apache.org/xmlrpc/advanced.html
>
> --
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>  -- (Terry Pratchett, Thief of Time)
>



-- 

Helder Ribeiro

Re: Problem with login using xml-rpc api

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Wed, Jul 2, 2008 at 3:15 PM, Helder Ribeiro <he...@gmail.com> wrote:
> This is the api documentation:
>
> http://www.bugzilla.org/docs/3.0/html/api/Bugzilla/WebService/User.html
>
> It says "
> *Returns*
>
> On success, a hash containing one item, id, the numeric id of the user that
> was logged in. A set of http cookies is also sent with the response. These
> cookies must be sent along with any future requests to the webservice, for
> the duration of the session.
> "
> but when I run the execute method in the client for the "Bug.login" method
> it returns a Map with only one property, the user id.

See the section on "Cookie handling" on

    http://ws.apache.org/xmlrpc/advanced.html

-- 
Look, that's why there's rules, understand? So that you think before
you break 'em.

 -- (Terry Pratchett, Thief of Time)

Re: Problem with login using xml-rpc api

Posted by Helder Ribeiro <he...@gmail.com>.
Sorry, its "User.login", not "Bug.login".

On Wed, Jul 2, 2008 at 6:15 AM, Helder Ribeiro <he...@gmail.com> wrote:

> This is the api documentation:
>
> http://www.bugzilla.org/docs/3.0/html/api/Bugzilla/WebService/User.html
>
> It says "
> *Returns*
>
> On success, a hash containing one item, id, the numeric id of the user
> that was logged in. A set of http cookies is also sent with the response.
> These cookies must be sent along with any future requests to the webservice,
> for the duration of the session.
> "
> but when I run the execute method in the client for the "Bug.login" method
> it returns a Map with only one property, the user id.
>
>
> On Wed, Jul 2, 2008 at 6:07 AM, Jochen Wiedmann <jo...@gmail.com>
> wrote:
>
>> On Wed, Jul 2, 2008 at 3:03 PM, Helder Ribeiro <he...@gmail.com>
>> wrote:
>>
>> > I tried to run the login before calling the create but. The login works
>> > fine, it returns the logged user id, but when I call the create I got
>> the
>> > same error.
>>
>> Do you have a pointer to the API of the login method? I could assume
>> that it does something like returning a Cookie that you need to pass
>> later on.
>>
>> Jochen
>>
>>
>> --
>> Look, that's why there's rules, understand? So that you think before
>> you break 'em.
>>
>>  -- (Terry Pratchett, Thief of Time)
>>
>
>
>
> --
>
> Helder Ribeiro




-- 

Helder Ribeiro

Re: Problem with login using xml-rpc api

Posted by Helder Ribeiro <he...@gmail.com>.
This is the api documentation:

http://www.bugzilla.org/docs/3.0/html/api/Bugzilla/WebService/User.html

It says "
*Returns*

On success, a hash containing one item, id, the numeric id of the user that
was logged in. A set of http cookies is also sent with the response. These
cookies must be sent along with any future requests to the webservice, for
the duration of the session.
"
but when I run the execute method in the client for the "Bug.login" method
it returns a Map with only one property, the user id.

On Wed, Jul 2, 2008 at 6:07 AM, Jochen Wiedmann <jo...@gmail.com>
wrote:

> On Wed, Jul 2, 2008 at 3:03 PM, Helder Ribeiro <he...@gmail.com> wrote:
>
> > I tried to run the login before calling the create but. The login works
> > fine, it returns the logged user id, but when I call the create I got the
> > same error.
>
> Do you have a pointer to the API of the login method? I could assume
> that it does something like returning a Cookie that you need to pass
> later on.
>
> Jochen
>
>
> --
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>  -- (Terry Pratchett, Thief of Time)
>



-- 

Helder Ribeiro

Re: Problem with login using xml-rpc api

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Wed, Jul 2, 2008 at 3:03 PM, Helder Ribeiro <he...@gmail.com> wrote:

> I tried to run the login before calling the create but. The login works
> fine, it returns the logged user id, but when I call the create I got the
> same error.

Do you have a pointer to the API of the login method? I could assume
that it does something like returning a Cookie that you need to pass
later on.

Jochen


-- 
Look, that's why there's rules, understand? So that you think before
you break 'em.

 -- (Terry Pratchett, Thief of Time)