有很多可能性。我认为 JSON 是优于 XML 的一个不错的选择。
对于 JSON,您能否使用 Google Gson(https://code.google.com/p/google-gson/)是一个非常有用且简单的库,可以转换 JSON-JAVA,反之亦然。
Java 对象序列化是另一种可能性。要通过套接字发送 java 对象,您可以这样做:
URL urlServlet = new URL("http://...");
URLConnection connection = urlServlet.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-Length",
"512");
connection.setRequestProperty("Content-Type",
"application/x-java-serialized-object");
ObjectOutputStream output = new ObjectOutputStream(connection.getOutputStream());
output.writeObject(getOrdenesDTO());