Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compare Java RPC vs WebServices

How do you compare Java RPC vs Java Web Services. I have a small hands on experience with Web Services. Now I need to know how RPC compares with Web Services. How does RPC work?

Addition : When do we go for either of the options?

like image 719
Ajay Avatar asked Aug 29 '09 08:08

Ajay


People also ask

What are the key differences between a remote procedure call PRC and a Web service invocation WSI )?

What are the key differences between a Remote Procedure Call (PRC) and a Web Service Invocation (WSI)? 1. PRC is platform-dependent; WSI is platform-independent.

Is RPC a webservice?

JAX-RPC is a technology for building Web services and clients that use remote procedure calls (RPC) and XML. Often used in a distributed client-server model, an RPC mechanism enables clients to execute procedures on other systems. In JAX-RPC, a remote procedure call is represented by an XML-based protocol such as SOAP.

Is RPC same as SOAP?

SOAP supports document-level transfer, whereas xml-rpc is more about values transfer, although it can transfer structures such as structs, lists, etc. xm-rpc is really about program to program language agnostic transfer. It primarily goes over http/https. SOAP messages can go over email as well.

What is the advantage of RPC?

Advantages of Remote Procedure Call Remote procedure calls support process oriented and thread oriented models. The internal message passing mechanism of RPC is hidden from the user. The effort to re-write and re-develop the code is minimum in remote procedure calls.


2 Answers

As Daff says, Java RMI itself is really only relevent to Java-to_Java communications. In terms of ease of development these days the degree of coding from the service provider's perspective is pretty similar.

However in addition to performance issues, where the gap between WebServices and RMI is quite variable (for some message sizes there can be negligable difference,) there's another aspect to consider: resilience.

Typically, RMI is easy to set up when one client talks to one server and you don't mind the availability of the client being coupled to that of the single server. Server down, client down, such is life.

In the Web Service case you can quite easily deploy your service to a cluster of servers and, given that you are invoking the Web Service over HTTP, you can easily exploit all the normal network routing and spraying techniques used in larger scale web sites. No special coding needed in the server or the client.

Now, you can get this same level of resilience with RMI, but that requires a slightly better service-provision infrastructure and thats's where the Java EE EJB programming model (or frameworks such as Spring) come in to play. EJB uses RMI over IIOP, a protocol that allows for resilient calling to server instances, transparently dealing with server outages. [It does quite a lot more too, such as secutiry and transactions, but then so can Web Services. Interesting but not part of this discussion.]

Bottom line: For production quality service provision I normally start by creating an service object. I happen to use Java EE EJB 3, other folks use Spring. You can expose that service object as a Web Service or as RMI/IIOP with some very simple configuration/annotation. It's very little effort to pick either or both. My world happens to major on interop, so I tend to expose Web Services. If you have only Java to consider it may give some performance improvement to use RMI/IIOP but this is not guaranteed, you would need to measure perfromance to be sure.

like image 79
djna Avatar answered Oct 16 '22 01:10

djna


My guess is, that you mean RMI with Java RPC. The remote method invocation is very Java specific, and therefore quite easy to handle in native Java programs (Java on both sides). It uses a binary format to transfer data and doesn't run over HTTP, so it is probably faster than the webservice solution.

Webservices on the other hand use (in general) a generic format like XML or JSON which can be requested and read by any other remote application. The overhead is bigger (making a http request and serializing/deserializing the data), but the client using a webservice doesn't care how the webservice generated that data and doesn't rely on a certain programming language as long as it is in a specified format.

So which technology you want to use depends on if there might be clients other than Java ones, that want to use your service.

like image 37
Daff Avatar answered Oct 16 '22 01:10

Daff