f_service_ <<
     indent() << argsname << " args = new " << argsname << "();" << endl <<
-    indent() << "args.read(iprot);" << endl <<
+    indent() << "try {" << endl;
+  indent_up();
+  f_service_ <<
+    indent() << "args.read(iprot);" << endl;
+  indent_down();
+  f_service_ << 
+    indent() << "} catch (TProtocolException e) {" << endl;
+  indent_up();
+  f_service_ <<
+    indent() << "iprot.readMessageEnd();" << endl <<
+    indent() << "TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());" << endl <<
+    indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl <<
+    indent() << "x.write(oprot);" << endl <<
+    indent() << "oprot.writeMessageEnd();" << endl <<
+    indent() << "oprot.getTransport().flush();" << endl <<
+    indent() << "return;" << endl;
+  indent_down();
+  f_service_ << indent() << "}" << endl;
+  f_service_ <<
     indent() << "iprot.readMessageEnd();" << endl;
 
   t_struct* xs = tfunction->get_xceptions();
 
   public static final int BAD_SEQUENCE_ID = 4;
   public static final int MISSING_RESULT = 5;
   public static final int INTERNAL_ERROR = 6;
+  public static final int PROTOCOL_ERROR = 7;
 
   protected int type_ = UNKNOWN;