Since I threw up my hands in disgust at trying to get python SOAP and
java SOAP to play nicely, I thought I'd try the simpler XMLRPC. I've
spent 3 days trying to get SOAP working and around 30 minutes getting
XMLRPC working. Here's what I did.
swamp_soapinterface.py's new main() method, at least the most relevent
part:
<code>
jm = StandardJobManager(confname)
server = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost",
48080))
server.register_instance(jm)
server.serve_forever()
</code>
Don't forget to import SimpleXMLRPCServer. Note that this exposes ALL
methods of the jm object, even the ones we shouldn't. It's rather
trivial to expose just those we want, but for simplicity this is all
I've done here.
Java example, in full:
<code>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package swampservicecloneclient;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient;
import org.apache.xmlrpc.client.XmlRpcClientConfigImpl;
/**
*
* @author d3n000
*/
public class Main {
private static final Logger logger = Logger.getLogger("");
static {
logger.setLevel(Level.ALL);
//logger.addHandler(new ConsoleHandler());
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws
MalformedURLException, XmlRpcException {
XmlRpcClient client = new XmlRpcClient();
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("
http://localhost:48080/RPC2"));
client.setConfig(config);
Object[] params = new Object[]{
new String("")
};
Integer result = (Integer) client.execute("newScriptedFlow",
params);
System.out.println(result);
}
}
</code>
And guess what? It worked! Now I can move on to more difficult
things. No WSDL needed.
I suppose so long as I wrap the swamp functionality in a nice Java
interface, swamp can change underneath without breaking my calling
classes. So much simpler. Why didn't I start here??