Indeed, that was one of the reasons to use URLConnection in the first place.Getting rid of the Apache HTTP library also removed dependencies on commons-codec and commons-logging, so this makes a huge difference to the client which would normally need to download these JAR files.
Ok, never mind, I worked it out (it is much simpler now): var session = JsonRpc.TransportRegistry.i().createSession(hostRoot + "JSON-RPC"); client = new JsonRpc.Client(session); var userManager = client.openProxy("userManager", Uidl.example.UserManager); Getting rid of the Apache HTTP library also removed dependencies on commons-codec and commons-logging, so this makes a huge difference to the client which would normally need to download these JAR files. Thanks! Dominic, On Jan 11, 5:00 pm, Dominic <dominic.cioccare...@gmail.com> wrote:Hi Sasha, On Jan 11, 4:33 pm, Sasha Ovsankin <sa...@codebistro.com> wrote:OK, so basically the built-in client supports proxies better than commons-httpclient? This is cool.Yep, exactly.Actually, the client does not need the dependency on the commons-httpclient unless you register it explicitly, so all is well :-)How does one do do this? My current code (sorry, in JavaScript) is: Client = Packages.org.apache.commons.httpclient; JsonRpc = Packages.org.jabsorb.client; JsonRpc.HTTPSession.register(JsonRpc.TransportRegistry.i()); var httpSession = JsonRpc.TransportRegistry.i().createSession(hostRoot + "JSON-RPC"); setProxy(httpSession); var state = new Client.HttpState(); httpSession.setState(state); client = new JsonRpc.Client(httpSession); var userManager = client.openProxy("userManager", Uidl.example.UserManager); So you are saying that I don't need to call httpSession.setState()? I could only find examples which used the Apache HTTP client. Regards, Dominic.
If the class specified by javaClass is missing, the error message does not include the name of the missing class.
It’s a simple change to JSONSerializer to print the missing class name.
private Class getClassFromHint(Object o) throws UnmarshallException
{
if (o == null)
{
return null;
}
if (o instanceof JSONObject)
{
String class_name = "(unknown)";
try
{
class_name = ((JSONObject) o).getString("javaClass");
Class clazz = Class.forName(class_name);
return clazz;
}
catch (Exception e)
{
throw new UnmarshallException("Class specified in hint not found: " + class_name, e);
}
}
if (o instanceof JSONArray)
{
JSONArray arr = (JSONArray) o;
if (arr.length() == 0)
{
throw new UnmarshallException("no type for empty array");
}
// return type of first element
Class compClazz;
try
{
compClazz = getClassFromHint(arr.get(0));
}
catch (JSONException e)
{
throw (NoSuchElementException) new NoSuchElementException(e.getMessage()).initCause(e);
}
try
{
if (compClazz.isArray())
{
return Class.forName("[" + compClazz.getName());
}
return Class.forName("[L" + compClazz.getName() + ";");
}
catch (ClassNotFoundException e)
{
throw new UnmarshallException("problem getting array type", e);
}
}
return o.getClass();
}
If the class specified by javaClass is missing, the error message does not include the name of the missing class.
It's a simple change to JSONSerializer to print the missing class name.