Rana Banerjee
2012-09-25 08:49:43 UTC
Hi,
I am using Apache Xml-Rpc 3.1.3 api to connect to Bugzilla 4.2.3. Once I successfully login to Bugzilla, all subsequent rpc calls are throwing XmlRpcException : You must log in before using this part of Bugzilla.
Here's my code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class Test
{
public static final String BUGZILLA_URI = "http://******/Bugzilla/";
public static final String RPC_PATH = "xmlrpc.cgi";
public static final String USER_NAME = "****";
public static final String PASSWORD = "****";
public static void main(String[] args)
{
XmlRpcClient rpcClient = null;
XmlRpcClientConfigImpl config = null;
List<Object> loginParams = new ArrayList<Object>();
Map<String, Object> loginData = new HashMap<String, Object>();
loginData.put("login", USER_NAME);
loginData.put("password", PASSWORD);
loginData.put("remember", true);
loginParams.add(loginData);
try
{
config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(BUGZILLA_URI + RPC_PATH));
rpcClient = new XmlRpcClient();
rpcClient.setConfig(config);
// Login
Object loginResult = rpcClient.execute("User.login", loginParams);
System.out.println("loginResult :::" + loginResult);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (XmlRpcException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
//Logout
Object logoutResult = null;
try
{
logoutResult = rpcClient.execute("User.logout", loginParams);
}
catch (XmlRpcException e)
{
e.printStackTrace();
}
System.out.println("logoutResult :::" + logoutResult);
}
}
}
And here's the stack trace :
loginResult :::{id=2}
org.apache.xmlrpc.XmlRpcException: You must log in before using this part of Bugzilla.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at com.rs.bugzilla.Test.main(Test.java:64)
logoutResult :::null
The Bugzilla parameter "rememberlogin" in Bugzilla installation is set to "defaulton", as mentioned in the api.
Can anybody explain what is wrong here? Or, what should I do to resolve this issue?
Regards,
Rana Banerjee
I am using Apache Xml-Rpc 3.1.3 api to connect to Bugzilla 4.2.3. Once I successfully login to Bugzilla, all subsequent rpc calls are throwing XmlRpcException : You must log in before using this part of Bugzilla.
Here's my code:
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
public class Test
{
public static final String BUGZILLA_URI = "http://******/Bugzilla/";
public static final String RPC_PATH = "xmlrpc.cgi";
public static final String USER_NAME = "****";
public static final String PASSWORD = "****";
public static void main(String[] args)
{
XmlRpcClient rpcClient = null;
XmlRpcClientConfigImpl config = null;
List<Object> loginParams = new ArrayList<Object>();
Map<String, Object> loginData = new HashMap<String, Object>();
loginData.put("login", USER_NAME);
loginData.put("password", PASSWORD);
loginData.put("remember", true);
loginParams.add(loginData);
try
{
config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL(BUGZILLA_URI + RPC_PATH));
rpcClient = new XmlRpcClient();
rpcClient.setConfig(config);
// Login
Object loginResult = rpcClient.execute("User.login", loginParams);
System.out.println("loginResult :::" + loginResult);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
catch (XmlRpcException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
//Logout
Object logoutResult = null;
try
{
logoutResult = rpcClient.execute("User.logout", loginParams);
}
catch (XmlRpcException e)
{
e.printStackTrace();
}
System.out.println("logoutResult :::" + logoutResult);
}
}
}
And here's the stack trace :
loginResult :::{id=2}
org.apache.xmlrpc.XmlRpcException: You must log in before using this part of Bugzilla.
at org.apache.xmlrpc.client.XmlRpcStreamTransport.readResponse(XmlRpcStreamTransport.java:197)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:156)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcSunHttpTransport.sendRequest(XmlRpcSunHttpTransport.java:69)
at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:158)
at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:147)
at com.rs.bugzilla.Test.main(Test.java:64)
logoutResult :::null
The Bugzilla parameter "rememberlogin" in Bugzilla installation is set to "defaulton", as mentioned in the api.
Can anybody explain what is wrong here? Or, what should I do to resolve this issue?
Regards,
Rana Banerjee