Overview
Development
Getting Started
Download
Mailing Lists
Todos
Credits


Required Software

Getting HTTPRemoting

The easiest way to get the latest released sources is from the download site.

To get the latest sources from cvs, provide this information to your cvs-client :

  • Connection type: pserver
  • User: anonymous
  • Password:
  • Host: cvs.sourceforge.net
  • Port: 2401 (which is the default)
  • Repository path: /cvsroot/httpremoting
  • Label: :pserver:anonymous@cvs.sourceforge.net:/cvsroot/httpremoting

Then checkout module httpremoting.

Installation

You just need to extract the downloaded module.

Build from the source

If you want to build the project from the sources you need to have Jakarta ANT 1.5+, then you just need to run "ant build", it'll build the project and put the distribution(httpremoting.jar) on <httpremoting-home>/build/dist folder.

Start using HTTPRemoting with a simple sample

Let's try HTTPRemoting by a simple sample,

1. Put <httpremoting-home>/lib/*.jar and <httpremoting-home>/build/dist/httpremoting.jar in your Classpath

2. Define interface of your services, We call it EchoService as follows:

public interface EchoService {
       public String echo(String echo) throws RemotingException;
}

All service methods need to throw "org.art.remoting.invocation.RemotingException"

3. Implement the service:

public class EchoServiceImpl implements EchoService{
       public String echo(String echo) throws RemotingException {
            return "echo " + echo;
       }
}

4. Define the service in a file named remoting-services.xml :

<?xml version="1.0" ?>

<services>

    <service interface="EchoService" class="EchoServiceImpl"/>

</services>
 

each service needs to be defined here to be remotable by the HTTPRemoting framework.

Note: Make sure to put remoting-services.xml in your classpath.

5. HTTPRemoting framework can be easily run and tested via Jetty Open Source Servlet container, Although it can run on every Servlet 2.x compliant J2EE Servlet Container.

For starting Jetty Web Container and testing the framework run the following command in a separate console window:

java org.art.remoting.transport.http.server.JettyWebContainer <port>

by default it uses port 80 but you can specify another port by passing the port number to the program.

6. Now the Web Container is started , your service has been deployed and is ready to accept invocations, let's write a test client:

public class EchoServiceTestClient {
      public static void main(String[] args) throws Exception{

          Map env = new HashMap();
          env.put(ServerContext.PROVIDER_URL,"http://localhost:8080");


          ServerContext serverContext = new ServerContext(env);
          EchoService echoService = (EchoService)serverContext.getService(EchoService.class);
          String res = echoService.echo("alireza");

          System.out.println("echo response = " + res);


       }
}

put httpremoting.jar and EchoService.class in the classpath and run the following command in a separate console window:

java EchoServiceTestClient

It should work!