When activating RPC, the server crashes.
BTW is there a documentation of RPC commands ?
2011-04-14/12:39:16.235/CEST WARN AllMarkets - Enabling RPC server access.
Exception in thread "main" java.lang.IllegalStateException: Invalid parameter or result type: net.commerce.zocalo.currency.Price
at org.apache.xmlrpc.common.TypeConverterFactoryImpl.getTypeConverter(TypeConverterFactoryImpl.java:293)
at org.apache.xmlrpc.server.ReflectiveXmlRpcHandler$MethodData.<init>(ReflectiveXmlRpcHandler.java:44)
at org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.<init>(ReflectiveXmlRpcHandler.java:70)
at org.apache.xmlrpc.metadata.ReflectiveXmlRpcMetaDataHandler.<init>(ReflectiveXmlRpcMetaDataHandler.java:51)
at org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.newXmlRpcHandler(AbstractReflectiveHandlerMapping.java:177)
at org.apache.xmlrpc.server.AbstractReflectiveHandlerMapping.registerPublicMethods(AbstractReflectiveHandlerMapping.java:158)
at org.apache.xmlrpc.server.PropertyHandlerMapping.addHandler(PropertyHandlerMapping.java:108)
at net.commerce.zocalo.rpc.RPCServer.run(RPCServer.java:62)
at net.commerce.zocalo.service.AllMarkets.runRPCServer(AllMarkets.java:59)
at net.commerce.zocalo.service.AllMarkets.main(AllMarkets.java:51)
I'm not sure what's causing the exception. I'll take a look this weekend.
There isn't any documentation of the RPC mechanism. I had hoped to publish sample code, but it was written by the same student who wrote the RPCServer class, and he never got permission from his university to release it as open source. Here's a quick sketch:
These are the public methods in RPCServer:
String closeMarket(String userName, String marketName, String position)
String createMarket(String userName, String marketName, String outcomes, String description, int endowAMM)
Quantity getCurrentBalance(String userName)
Price getMarketMakerPrice(String marketName, String positionName)
String grantCash(String userName, BigDecimal amt)
String tradeClaim(String userName, String marketName, String buySell, String position, Price price, int shares)
String transferCash(String fromUserName, String toUserName, BigDecimal amt)
The way you call createMarket is as follows. I've left out exception handling and other important stuff.
Vector<Object> params = new Vector<Object>();
params.addElement("Admin");
params.addElement("Stanley Cup");
params.addElement("Sharks,RedWings,Vancouver");
params.addElement("Who will win the Stanley Cup?");
params.addElement("1000");
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(new URL("http://localhost:8180/RPC2"));
XmlRpcClient client = new XmlRpcClient();
client.setConfig(config);
Object result = client.execute("markets.createMarket", params);
if (result != null && result instanceof String){
return (String)result;
}
return null;
I've found and fixed the problem. I have uploaded a release for linux only. If you need a Window installer, let me know, and I'll add it.