I think you should use Serializable and Deserializable to send and recieve Xml to Object and Object to Xml for example you can using hashTable to
put your environment in it
for example in java 5 and EJB3.0 :
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL, "jnp://localhost:1099"); // remote machine IP
try {
InitialContext context = new InitialContext(environment);
RemoteAgentFacade rbi = (RemoteAgentFacade) context.lookup(RemoteAgentFacade.class.getName());
if(rbi.canLogin("Hatami")) {
System.out.println("Ok");
}
and you should have specify LoginModule for your connection to server that able to across SSL and using JAAS for LoginModule.