简体   繁体   中英

XML-RPC to connect confluence in JAVA

I have to use XML-RPC to upload a picture to confluence in JAVA.

JAVA CODE

import java.util.Vector;
import java.util.Hashtable;
import helma.xmlrpc.*;
import java.util.Arrays;

public class test {

    // The location of our server.
    private final static String server_url =
        "http://confluence.xyz.com:8080/rpc/xmlrpc";

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

            // Create an object to represent our server.
            XmlRpcClient server = new XmlRpcClient(server_url);

            Vector<Object> params = new Vector<Object>();
            params.add("username");
            params.add("pass");

            String token = (String) server.execute("confluence2.login", params );
            System.out.println(token);
        }
         catch (Exception exception) {
            System.err.println("JavaClient: " + exception.toString());
        }
    }
}

I am getting error

JavaClient: java.io.IOException: SAX driver not found: org.apache.xerces.parsers.S

You need to put additional xercesImpl-2.2.1.jar for this. If you were using maven ,you can just simply add xercesImpl maven dependency as below:

<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.2.1</version>
</dependency>

Hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM