Return-Path: Delivered-To: apmail-archiva-dev-archive@www.apache.org Received: (qmail 44530 invoked from network); 4 Sep 2008 05:03:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Sep 2008 05:03:23 -0000 Received: (qmail 20614 invoked by uid 500); 4 Sep 2008 05:03:21 -0000 Delivered-To: apmail-archiva-dev-archive@archiva.apache.org Received: (qmail 20577 invoked by uid 500); 4 Sep 2008 05:03:21 -0000 Mailing-List: contact dev-help@archiva.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@archiva.apache.org Delivered-To: mailing list dev@archiva.apache.org Received: (qmail 20566 invoked by uid 99); 4 Sep 2008 05:03:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2008 22:03:21 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [63.246.22.40] (HELO mail.atlassian.com) (63.246.22.40) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Sep 2008 05:02:21 +0000 Received: from [192.168.3.44] (unknown [203.63.130.33]) by mail.atlassian.com (Postfix) with ESMTP id C7C241631E90 for ; Thu, 4 Sep 2008 00:02:21 -0500 (CDT) Subject: Re: MRM-124 - XML RPC Web Services From: James William Dumay To: dev@archiva.apache.org In-Reply-To: <1220504136.18580.26.camel@heck> References: <1220504136.18580.26.camel@heck> Content-Type: text/plain Organization: Atlassian Ltd Date: Thu, 04 Sep 2008 15:02:24 +1000 Message-Id: <1220504544.18580.28.camel@heck> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Oh I also forgot - the API docs for the Binder project are available from this page: http://docs.atlassian.com/atlassian-xmlrpc-binder/0.7/apidocs/ Cheers James On Thu, 2008-09-04 at 14:55 +1000, James William Dumay wrote: > Hey guys, > I created a branch for MRM-124 - support for web services using XML-RPC > - which I am proposing to merge into trunk. > > https://svn.apache.org/repos/asf/archiva/branches/MRM-124 > > It introduces two new modules - Archiva XML-RPC API and Archiva XML-RPC > Services. These two modules use the library I wrote at Atlassian > imaginatively called "Atlassian XML-RPC Binder" which is a companion > library to the Apache XML-RPC client and servlet which makes XML-RPC > using Java easy and type safe. It is licensed under the Apache 2 > license. > > So, let me explain how it works :) > > Here is a example application that uses the "test" XML-RPC service > included on the branch. > > package com.mycompany.testservicething; > > import com.atlassian.xmlrpc.Binder; > import com.atlassian.xmlrpc.DefaultBinder; > import java.net.URL; > import org.apache.maven.archiva.web.xmlrpc.api.TestService; > > public class App > { > public static void main( String[] args ) throws Exception > { > URL url = new URL("http://localhost:8080/archiva/xmlrpc"); > > Binder binder = new DefaultBinder(); > > TestService service = binder.bind(TestService.class, url); > System.out.println(service.ping()); //will output "pong" > } > } > > When bind() is called, we pass an interface class type that represents > the remote service and the URL of the xmlrpc servlet and it then returns > a dynamic proxy object of that interface. > > The object returned is a type safe instance of the remote service - so > when ping() is called we are actually calling ping on the xmlrpc > service. > > The interface looks a like this: > > import com.atlassian.xmlrpc.ServiceObject; > > @ServiceObject("Test") > public interface TestService > { > public String ping(); > } > > The ServiceObject annotation denotes that this is a xmlrpc service with > the object name of "test". > > The server side object looks like this: > > import org.apache.maven.archiva.web.xmlrpc.api.TestService; > > public class PingServiceImpl implements TestService > { > public String ping() > { > return "pong"; > } > } > > As you can see, the interface for accessing the service and implementing > the server side service are the same (yay for interfaces). > > The best part about this is that anyone using the XML-RPC service to > talk to Archiva using java will be type safe the entire time they are > using it. > > Services are easily registered with the servlet by appending bean > references to the applicationContext.xml "xmlrpcServicesList" list bean > - when the servlet initialises it looks for this list in the spring > ApplicationContext and allows clients to start accessing the services > defined. There is no need for a servlet subclass. > > If you wondering how to return POJO's (or lists of them) take a look at > the following test case: > https://svn.atlassian.com/svn/public/atlassian/xmlrpcbinder/trunk/binder/src/test/java/com/atlassian/xmlrpc/BeanServiceTest.java > > > Anyway, would love to hear your thoughts, questions and complaints :) > > Cheers > James >