http://caucho.com/hessian/ Resin 을 이용하는 경우라면 Hessian 이용해서 간단하게 RPC 를 구현할 수 있다. hessian simple tutorial (홈페이지의 Servlet 예제) - 이는 Resin Servlet Container 가 동작해야 함. === interface 의 정의 === RPC 를 위해서는 서버-클라이언트의 대화를 위한 interface 의 정의가 필요하다. 간단하게 정의해본다. Basic.java {{{~cpp public interface Basic { public String hello(); public int returnInt(); } }}} === RPC Service 구현 === 그리고 RPC Test 를 구현해보자. (여기선 Hessian Servlet 을 이용) 이를 컴파일 하기 위해서는 hessian-2.1.3.jar 화일과 jsdk23.jar, resin.jar 화일이 classpath 에 맞춰줘야 한다. (이는 resin 의 lib 폴더에 있다. hessian jar 화일은 [http://caucho.com/hessian/download/hessian-2.1.3.jar hessian] 를 다운받는다) {{{~cpp import com.caucho.hessian.server.HessianServlet; public class RpcTest extends HessianServlet implements Basic { public String hello () { return "Hello, World"; } public int returnInt() { return 10; } }}} 그리고 class 화일을 Servlet 이 돌아가는 디렉토리에 복사한다. 이로서 RPC Publish 기본준비는 ok. === RPC Client 구현 === Java 와 Python 둘 다 구현이 가능하다. 여기서는 간단하게 Python Interpreter 를 이용해보자. Python 모듈은 http://caucho.com/hessian/download/hessianlib.py 를 다운받는다. {{{~cpp >>> import hessianlib >>> proxy = hessianlib.Hessian("http://localhost:8080/servlet/RpcTest") >>> proxy.hello() 'Hello, World' >>> proxy.returnInt() 10 >>> }}} Java 의 경우는 다음과 같다. 위에서 정의한 interface 인 Basic 이 있어야 한다. {{{~cpp import com.caucho.hessian.client.HessianProxyFactory; import java.net.MalformedURLException; public class RpcClient { public static void main(String[] args) throws MalformedURLException { String url = "http://localhost:8080/servlet/RpcTest"; HessianProxyFactory factory = new HessianProxyFactory(); Basic basic = (Basic)factory.create(Basic.class, url); System.out.println("Hello ():" + basic.hello()); System.out.println("returnInt : " + basic.returnInt()); } }}} ---- ["Hessian/Counter"] See Also PythonXmlRpc ---- ["Java"]