Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Post a Maven "workaround" that I used to get the examples to work. I'm not an expert in this library and didn't fully test it; 3.0.4 is in maven central and may be more compatible with 3.0.1 if anyone has problems with 3.1.0

...

The sources can be found here : XML-RPC.
For a binary download, go to the repository.
If you are using maven to download your dependencies, you won't find all the dependencies in the Maven 2 Repo yet.
The missing dependency (smack) can be manually downloaded from here.
If you are using POMs, the following workaround can be used, to use smack 3.1.0 instead of 3.0.1:

Code Block
xml
xml

<dependency>
	<groupId>org.codehaus.groovy</groupId>
	<artifactId>groovy-xmlrpc</artifactId>
	<version>0.7</version>
	<!-- The version of smack is NOT in Maven central -->
	<exclusions>
		<exclusion>
			<groupId>jivesoftware</groupId>
			<artifactId>smack</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<!-- So, we define our own smack dependency -->
<dependency>
	<groupId>org.igniterealtime.smack</groupId>
	<artifactId>smack</artifactId>
	<version>3.1.0</version>
</dependency>

Sample scripts

  • Confluence Example showing how to download a secured Confluence page.
  • Another example inspired by Glen's Confluence example:
    Code Block
    import groovy.net.xmlrpc.*
    
    def c = new XMLRPCServerProxy("http://docs.codehaus.org/rpc/xmlrpc")
    def token = c.confluence1.login("your_username","your_password")
    // print all the code snippets from the Groovy Home page
    def page = c.confluence1.getPage(token, "Groovy", "Home")
    def incode = false
    def separator = '////////////////////////////////////'
    page.content.split('\n').each{
        if (it =~ /\{code\}/) {
            incode = !incode
            if (incode) println separator
            return
        }
        if (incode) print it
    }
    println separator
    
    Which results in (at least around December 2007) the following:
    Code Block
    ////////////////////////////////////
    def name='World'; println "Hello $name!"
    ////////////////////////////////////
    class Greet {
      def name
      Greet(who) { name = who[0].toUpperCase() +
                          who[1..-1] }
      def salute() { println "Hello $name!" }
    }
    
    g = new Greet('world')  // create object
    g.salute()              // Output "Hello World!"
    ////////////////////////////////////
    import static org.apache.commons.lang.WordUtils.*
    
    class Greeter extends Greet {
      Greeter(who) { name = capitalize(who) }
    }
    
    new Greeter('world').salute()
    ////////////////////////////////////
    groovy -e "println 'Hello ' + args[0]" World
    ////////////////////////////////////