简体   繁体   中英

Is Java RMI a good alternative to Axis2 SOAP?

If server and client are Java only, would RMI be more efficient (bandwidth and latency) compared to SOAP implemented by Axis2? I know RMI has lost popularity on late years, but that doesn't mean it can't be used.

And how about XML-RPC?

RMI has some interesting features and is reasonably fast, but also has some problems:

  1. You have to make sure everything you're serializing implements Serializable.
  2. You have to make sure the server and client have exactly the same version of all the Serializable classes, and are deployed at exactly the same time, and that every class that you serialize (including fields held by the serializable objects) uses serialVersionUID appropriately. Otherwise you will be in a world of pain (read: "serial version mismatch").
  3. You have to ensure that the classes that you serialize are not holding onto references to objects that eventually hold references to large objects, or else you will be very surprised about the size of the packets going over the wire.
  4. If you ever decide to access the service from anything but Java, you will have to write another remote access layer.
  5. There is no #5.

In practice, I would almost always recommend a REST service these days. It's so easy to create small Java objects and use Gson or Jackson or something to marshal the data back and forth that the advantages of RMI are vanishingly small in comparison.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM