Testopia:Documentation:XMLRPC:Newer Client Example: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(New page: The original example given uses the original version of xmlrpc, whereas only xmlrpc-2 might be available on your system. The following code worked for me on FC7. Note: * I stripped out a...)
 
No edit summary
Line 3: Line 3:
* Your compiler will probably complain about using setBasicAuthentication as it is deprecated
* Your compiler will probably complain about using setBasicAuthentication as it is deprecated
* If you get an error like "XmlRpcException: Login Required", you will need to edit your apache conf file per [[Testopia:Documentation:XMLRPC:Apache| this]].  In my case I eliminated the AuthUserFile and Require valid-user.
* If you get an error like "XmlRpcException: Login Required", you will need to edit your apache conf file per [[Testopia:Documentation:XMLRPC:Apache| this]].  In my case I eliminated the AuthUserFile and Require valid-user.
* If you are getting an HTTP 500 response, have a look at your apache logs and see if you haven't hit [https://bugzilla.mozilla.org/show_bug.cgi?id=396399 bug 396399].  The workaround is given in the bug.
* If you are getting an HTTP 500 response, have a look at your apache logs and see if you haven't hit [https://bugzilla.mozilla.org/show_bug.cgi?id=396399 bug 396399].  The workaround is given in discussion [http://groups.google.com/group/mozilla.support.webtools/browse_thread/thread/950d3621f12420e9/1613c2cf336cf2a6#1613c2cf336cf2a6 here]


<pre>
<pre>

Revision as of 22:45, 20 September 2007

The original example given uses the original version of xmlrpc, whereas only xmlrpc-2 might be available on your system. The following code worked for me on FC7. Note:

  • I stripped out all the SSL stuff and switched to using very basic Hashtables and Vectors
  • Your compiler will probably complain about using setBasicAuthentication as it is deprecated
  • If you get an error like "XmlRpcException: Login Required", you will need to edit your apache conf file per this. In my case I eliminated the AuthUserFile and Require valid-user.
  • If you are getting an HTTP 500 response, have a look at your apache logs and see if you haven't hit bug 396399. The workaround is given in discussion here
import org.apache.xmlrpc.XmlRpcClient;

import java.util.Hashtable;
import java.util.Vector;
import java.lang.Integer;

public class RPCClient
{

    public static void main(String[] args)
    {
         try
        {


            XmlRpcClient client = new XmlRpcClient("http://bugzilla.mycompany.com/bugs/tr_xmlrpc.cgi");
            client.setBasicAuthentication("me@mycompany","password");

            Vector params = new Vector();
            params.add(new java.lang.Integer(2));

            Hashtable result = (Hashtable) client.execute("TestPlan.get", params);

            System.out.println(result);
        }
         catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}