5. Pass-Through, or Proxy ServicesSwitchRMI offers the ability to place a proxy service between a client applciation and the actual implementation. This allows you to control access to these services through a firewall or to offer the same service over one of the other RMI protocols supported by SwitchRMI. Since clients communicate with the proxy service and not the actual service and can use any of the supported RMI protocols a XMLRPC service could be exposed via another protocol (SOAP, for example, once it is implemented). Once again the remote service must have a Java interface and a deployment descriptor. The following example illustrates a proxy for the O'Reilly Meerkat XMLRPC service. This descriptor is part of the JUnit test suite which ships in the SwitchRMI source code. This object allows a SwitchRMI client to use the internal raw, serializable protocol to interact with the Meerkat XMLRPC services. <object name="meerkat-proxy" scope="application"> <proxy url="http://www.oreillynet.com/meerkat/xml-rpc/server.php" protocol="xmlrpc" /> <interface class="com.mjh.switchrmi.protocol.xmlrpc.IMeerkat" /> </object>
In this case the deployment descriptor contains a import com.mjh.switchrmi.*; import com.mjh.switchrmi.protocol.xmlrpc.*; private RmiClient rmi; private IMeerkat meerkat; try { rmi = new RmiClient(); meerkat = rmi.connect("http://localhost:8080/rmi/meerkat-proxy.raw", IMeerkat.class); List channels = meerkat.getChannels(); } catch (Exception ex) { } |