Esempio n. 1
0
  /** Creates an XMLRPC call from the given method name and parameters and sends it */
  protected void writeCall(String methodName, Object[] args) throws Exception {
    huc = u.openConnection();
    huc.setDoOutput(true);
    huc.setDoInput(true);
    huc.setUseCaches(false);
    huc.setRequestProperty("Content-Type", "binary/message-pack");
    huc.setReadTimeout(0);
    OutputStream os = huc.getOutputStream();
    Packer pk = new Packer(os);

    pk.packArray(args.length + 1);
    pk.pack(methodName);
    for (Object o : args) pk.pack(o);
    os.close();
  }
 @Override
 @SuppressWarnings("unchecked")
 public void pack(Packer pk, Object obj) throws IOException {
   if (obj instanceof Map) {
     Map d = (Map) obj;
     pk.packArray(fields.length);
     for (int i = 0; i < fields.length; ++i) {
       FieldSchema f = fields[i];
       f.getSchema().pack(pk, d.get(f.getName()));
     }
   } else if (obj == null) {
     pk.packNil();
   } else {
     throw MessageTypeException.invalidConvert(obj, this);
   }
 }
 @Override
 public void messagePack(Packer packer) throws IOException {
   packer.packArray(2);
   packer.pack(f0);
   packer.pack(f1);
 }