The difference between Web service and EJB

Source: Internet
Author: User

WebService can be said to be cross-platform, because it is the use of XML technology, it is to put your request in accordance with the criteria of the webservece passed the parameters, and then the server returned the results, of course, the most important thing is that the parameters of the transfer and return of the results are in XML format, But by specification, there are now soap and ebXML, and when it comes to XML that naturally has a DTD or schema, it uses WSDL and UDDI to manage these specifications.

EJBS can also be described as remote calls, but the protocol used is RIM/IIOP, the client encapsulates the method request in accordance with the Protocol, and then sends it to the server, which returns the result to the client. Because of the protocol, the data we transmit can be seen as binary data and WebService (transfer XML text data) differently.


WebService provides a cross-platform, heterogeneous method invocation that is typically used to implement some kind of business logic process.
EJB provides a more precise method invocation, and typically multiple ejbs to implement certain business logic.

Generally you can use WebService to provide user calls, specifically how to implement the EJB to do.

2.

Distributed EJB: A business logic may invoke EJB components distributed across multiple servers, but so many component calls must be included in a transactional scope. That is, if you need to invoke three EJB components, the first call succeeds, the second one succeeds, but the third one fails, so the transaction operation occurs when the first and second invocations succeed (the transaction operations here do not refer to the database alone, and the transaction that may include the Message Queuing service) must be rolled back.


However, if you call three WebService, The two successful calls are basically impossible to rollback, the call is finished.

webservice is just a calling interface provided externally, and the EJB It's a business component.

The Servlet can only be considered a client of a Web-level invocation relative to the EJB server. An EJB component is not only used in the application of B/s structure, but also in the application of C/s structure. This also can clarify a lot of people's misunderstanding, that Java Web is the EE, in fact, the Java EE is a series of specification set, and the Web is just a small part of the EE many specifications. Java EE most of the other specifications are defined by the service side of the thing, as a specific client call, can be B/s, or C/s.

3.

WebService mainly focus on the solution of heterogeneous systems, different language system communication, which is concerned about the development of distributed services, start point to High, high point of view, and EJB can be seen as a distributed programming platform, through the container and components, simplifying the development of programs, debugging and deployment of its focus on the development of distributed components, Small granularity.

Web Service can be seen as a standard for communication between heterogeneous systems and heterogeneous language systems, and EJBS are only part of the Java EE specification.

EJB is a specification in Java EE that describes the issues that a distributed application needs to address, such as transaction processing, security, logging, distribution, and so on, while Sun has implemented its own definition of the standard, equivalent to enacting a standard, and then giving the realization for others to use, Implementations are provided to people in a number of API ways.

EJB is a Java class defined by the Java server interface, can be understood as a special Java class, placed in a container can help the class management transactions, distributed, security, and so on, the general small program will not be used, only large distributed systems will use the EJB, Since the EJB is a Java class or a component, the particle size is small, which is also one of the differences from WebService, which can be said to be called by one or more modules.

Contains three types of beans, which can be tagged by annotating the JPA specification, which has a bean called an MDB message-driven bean whose communication mechanism involves the JMS protocol.

EJBS can make remote calls, but not across languages, andEJBs are synchronous calls, while the EJB asynchronous calls we call refer to the EJB's MDB asynchronous communication

The difference between Web service and EJB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.