java remote call method summary

java remote call method summary

Foreword: The remote calling methods such as RMI and webService are used in the project, and the demo output of each method is summarized.
  • Java RMI (Remote Method Invocation)
  • WebService,如jax-ws axis xfire cfx
  • Httpinvoker
  • Hessian
  • Burlap
  • EJB remote interface call

1、Java RMI (Remote Method Invocation)

       JavaRMI is remote method invocation. It is a bottom-level solution embedded in jdk. It is the most lightweight and simplest to apply. It does not require any web server, and directly binds the IP address and the corresponding code in the code. Port for very simple small micro applications .

       advantage:

  • Full object support: RMI can pass full objects as parameters and return values, not just predefined data types.
  • Cross platform: Binding with java language, RMI only supports Java;
  • Robust communications : reliable transmission
  • Large objects: This advantage is not well understood, and a rough understanding can pass large objects;
  • Security for client and servers: RMI uses Java's built-in security mechanisms to ensure the security of user systems when downloading and executing programs. RMI uses a security management program designed specifically to protect the system from malicious applets.
  • Distribution/updates of codes: The remote interface is actually a Java interface, and interface-oriented programming can easily upgrade function codes;

shortcoming:

  • Java RMI only supports Java: For remote invocation of Java language, the programming language at both ends must be implemented in Java;
  • Requires non-standard port: RMI is closely dependent on the IP address and port of the server, but it does not know the future server IP and port during development, but the client program depends on this IP and port. This is also one of the limitations of RMI. There are two ways to solve this problem: one is to solve it through DNS, and the other is to expose IP to the program code through encapsulation.
  • Proprietary protocol by single vendor: RMI relies on the Java Remote Messaging Protocol (JRMP), which is customized for Java and requires both the server and the client to be written in Java;
  • Requires RMI-lookup: Registration is required (don't understand why this is a bug).

       See the attachment for RMI_Demo.

2、WebService,如jax-ws axis xfire cfx

       WebService is a very common remote invocation method, and its biggest advantage is that it is a cross-platform language, and it can be easily invoked whether the client is Java or .NET. It uses the SOAP (Simple Object Access Protocol) protocol to encapsulate the serialized message, which actually forms an xml file, which can be transmitted over the network through http. The client invocation of WebService actually uses the method of generating files, as long as you know the URL of the publishing interface, and there is no need to pass additional jar packages or class files. Common WebService implementations include jax-ws2.0, axis, xfire and cfx, of which jax-ws2.0 is encapsulated in jdk and has a certain degree of flexibility, but this kind of embedding the framework into the JVM is actually controllable. The performance is greatly reduced; there are two versions of axis, 1.0 and 2.0, which are not too well understood; xfire and cfx are actually a source, xfire stopped development in 2007, and merged with another framework to form cfx, which is a relatively popular WebService implementation .

      The main goal of WebServices is cross-platform interoperability .

       advantage:

  • Communication across firewalls: Generally, the Web server to be accessed and the client of the Web Service to be accessed are likely to be located behind the firewall, and other ports are closed by default and the HTTP port is opened, and the Web service is based on HTTP, so it can pass through the firewall. ;
  • Application integration: It can realize communication between different applications and applications developed on different system platforms. The biggest difference from RMI, DOCM, and CORBA is that Web Service uses SOAP as the basic communication protocol to avoid complex protocol conversion;
  • B2B Integration: Cross-company business transaction integration is often referred to as B2B integration. Through WebService, the company can "expose" key business applications to designated suppliers and customers. As long as the business logic is "exposed" to become WebService, any designated partner can call these business logic regardless of their business logic. What platform is the system running on and what development language is used. This greatly reduces the time and cost spent on B2B integration, making B2B integration accessible to many small and medium-sized businesses that would otherwise not be able to afford EDI.

        shortcoming:

  • Stand-alone application: As long as a stand-alone application communicates with other programs on the local machine, using WebService in this case consumes too much and will not bring any benefits;
  • Isomorphic applications for LANs: In short, a performance issue. As long as there are other methods that are more efficient and feasible than WebService from an application structure point of view, then don't use WebService.

3、Httpinvoker

        Spring HTTP invoker is a remote invocation model in the spring framework that performs HTTP-based remote invocation (meaning that it can pass through firewalls) and uses Java's serialization mechanism to pass objects across the network. Clients can easily call objects on remote servers as if they were local objects, which is somewhat similar to but different from webservices.

       Here is a simple comparison with WebService to introduce Httpinvoker:

webservice Http Invoker
Cross-platform, cross-language Only supports java language
Support SOAP, provide wsdl not support
The structure is huge and depends on a specific webservice implementation, such as xfire, etc. The structure is simple and only depends on the spring framework itself

 

 

 

 

 

 

 

4、Hessian

Hessian is an efficient and concise remote calling framework. It adopts the binary RPC protocol (Binary), which has the characteristics of light weight, small transmission volume, and platform-independent characteristics. It is especially suitable for mobile network application projects with relatively small network bandwidth. Similar to WebService, but instead of using SOAP protocol, Binary RPC protocol is used, which is simpler and faster than webservice. It encapsulates protocol packets into http packets and transmits them through the HTTP channel. Hessian provides remote services through servlets, which are completely implemented using dynamic proxies. Interface-oriented programming is recommended. Therefore, Hessian services are recommended to be exposed through interfaces.

       advantage:

  • Simple and easy to use, interface-oriented, expose services through the interface, the jar package is only 200, 300k, and there is no need to configure a firewall;
  • High efficiency, the serialization speed of complex objects is second only to RMI, and the serialization of simple objects is better than RMI, and binary transmission;
  • Multi-language support: wiki, Java , Flash/Flex, Python , C++, .NET C#, PHP , Ruby, Objective-C
  • Can be integrated with Spring, easy to configure, and use HessianServiceExporter to provide bean services.

        shortcoming:

  • Lack of security mechanism, transmission is not encrypted;
  • The exception mechanism is not perfect, some errors are always reported, the reasons for the errors are also various, and the prompt information is insufficient;
  • lack of transaction processing;
  • Version problems, the server side and the client side usually need to keep the same version, otherwise there will be inexplicable problems;
  • The supported data types are limited and complex objects are not supported.

 5、Burlap

    Burlap is to convert the objects transmitted by the network into XML text format for transmission through Http, and supports fewer objects than Hessian. XML generally takes up more space than binary stream, and it takes longer to transmit on the network than binary stream, and the parsing process of XML also consumes more memory. Burlap can penetrate firewalls, and because the transmission format is XML text, it can be integrated with other systems (such as .NET). To a certain extent, Burlap is a non-standard WebService.

   It doesn't seem to be commonly used.

6. EJB remote interface call

       At present, I have not been in contact with EJB, and have not done in-depth understanding.

 

Related Links:

http://developer.51cto.com/art/200906/130417.htm

http://blog.sina.com.cn/s/blog_5f53615f01014xfd.html

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326197200&siteId=291194637