Basic introduction WebService

What is WebService?

W3C organization is defined as follows them, it is a software system that interact with each other in order to support the operation across the network between the machine design. Web Service service is generally defined as a set of modular API, which can be called by the network to perform remote system requesting service.

Simply put: WebService That Web service, it is a call technical remote programming languages and across operating system platforms across.

The so-called cross-platform and cross-programming language, that is the server program using Java to write the client program you can use other programming language, and vice versa! Cross-operating system platform refers to the server program and the client program can run on different operating systems.

The so-called remote call is a program on one computer can call to a method of an object on another computer b. Weather Forecast for example obtained from a weather data system on display in the city's own system; obtaining a stock transaction information is displayed in its own system from securities trading system; Another example is a system able to demonstrate Mall Express tracking information, and data information is obtained from specific courier company system via webservice.

In fact, can be understood from various angles WebService, the surface, WebService is an application that exposes a Web through an API call to the outside world, that is to say the method can be programmed to call this application over the Web. We call this WebService application called the client, and to provide this WebService application called the service side. Look deeper, WebService is to build distributed applications interoperable new platform is a platform, is a set of standards. It defines how an application interoperability on the Web, you can use any language you like, you like to write on any platform Web service, as long as we can query and access to these services through Web service standards.

 

Web Service = SOAP + HTTP + WSDL. Wherein, SOAP Simple Object Access Protocol) protocol is a web service body, which communicates via SMTP or HTTP application layer protocols use the XML file itself functions to describe the methods and procedures of the parameter information, thereby completing the heterogeneous systems of different hosts computing services processing. Here's WSDL (Web Services Description Language) web service description language is an XML document, it was released to the public through HTTP, URL naming announcement client information on a specific Web service services, methods, parameters, return values, etc. .

basic concept

WebService three elements

SOAP (Simple Object Access Protocol): Simple Object Access Protocol, soap used to describe the transmission format information.

WSDL (WebServices Description Language): Web Services Description Language used to describe WebService, and how to access WebService

UDDI (Universal Description Discovery and Integration): Universal Description, Discovery and Integration for management, distribution,

Query webService.

What WSDL is, what role? WSDL document that several major parts, namely what role?

 

WSDL is an abbreviation web service definition language, i.e. the definition of the web service (description) language.

How to introduce to others what your web service function, and each function parameters when calling it? You could write your own set of documents, you may even need to verbally tell your web service of the people. These informal methods have at least one serious problem: when to sit before a computer programmer, when you want to use your web service, and their tools (such as Visual Studio) can not provide any help to them, simply because these tools do not understand your web service. The solution is to: provide a formal description of the document with the way the machine can read. web service description language (WSDL) is such an XML-based language for describing web service and the functions , parameters and return values. Because it is based on XML, WSDL is both machine-readable, but also human-readable, it will be a great advantage. Some of the latest development tools based on both your web service generates a WSDL document, and can import the WSDL document, generates a call to the corresponding web service code.

After the release Webservice service, accessible via a browser released +? Wsdl wsdl document can be obtained.

The root element of a WSDL document is the definitions elements, WSDL document contains seven important element: types, import, message, portType, operations, binding and service elements.

1, definitions elements typically comprise a plurality of XML namespaces;

2, Types element serves as a container, a special data type defines custom (payload) when, using the messages defined data element types and element types defined in the declaration message portion;

3, Import elements can have the current document using another WSDL document specifies the definition of the namespace;

4, Message element describes the payload Web services. It corresponds to the function call parameters and return values;

5, PortType element defines the abstract interface of the Web services, which may consist of one or more operation elements, each operation element defines a RPC Web service method of the document style or styles;

6, Operation elements use a plurality of messages or message to define its input, output, and error;

7, Binding abstract portType element will be mapped to a set of specific protocol (SOAP or HTTP), messaging style (RPC or document) and the coding pattern (or literal SOAP encoding);

8, Service Port element contains one or more elements of

each Port element corresponds to a different Web services, port will be given a URL to a specific binding, accomplished by location.
Port allows two or more different elements assigned to the same URL binding.

What SOAP is?

 

SOAP is an acronym for simple object access protocal, the Simple Object Access Protocol. It is based on XML and HTTP communication protocol. Webservice is a transmission protocol used, webservice are able to do cross-platform and cross-language, mainly because XML and HTTP are independent of language and platform. Soap messages consist of request and response messages, a SOAP message is an ordinary XML document containing the following elements:

1, required Envelope element, the XML document can be identified as a SOAP message

2, optional Header element contains header information

3, the required Body element contains all calls and responses

4, optional Fault element, providing information about the error that occurred in the process of this message

Soap request message 

Soap response message 

How to understand UDDI?

UDDI is Universal Description Discovery and Integration acronym, that Universal Description, Discovery and Integration specification. To register and lookup service, the web services to collect and store it, so that when someone would find access to this information from the UDDI see if there is no such information exists.

 

What Webservice of SEI refers to?

WebService EndPoint Interface (webservice terminal [Server side] Interface) is the interface to the server WebService processing request

 

What is the difference between SOA and Web service is?

SOA is a software design guidelines for implementing loosely coupled, web high reusability and coarse-grained services design patterns . Developers can select any of the SOA protocol, e.g., HTTP, HTTPS, JMS, SMTP , RMI, IIOP ( e.g., using the EJB IIOP), the RPC like. XML message or data transfer objects (Data Transfer Objects, DTOs) may be employed.

Web Service is one of the technologies to achieve SOA. Web service can not be implemented SOA applications: for example, using some traditional techniques, like Java RMI, EJB, JMS messages. But the Web service provides a standard platform-independent services that uses HTTP, XML, SOAP, WSDL and UDDI technology, so you can bring interoperability between J2EE and .NET these heterogeneous technologies (heterogeneous technologies).

Java development WebService two most important specifications:
JSR-224 (JAX-WS: Java API for XML-Based Web Services), mainly used soap protocol, using wsdl to describe;

JSR-311 (JAX-RS: The Java API for RESTful Web Services), described the use of wadl;

 

 

 

 

JAX-WS is for the WebService. The JAX-RS is for RESTful HTTP Service.

JAX-WS is a message-oriented, every request specifies a request method. JAX-RS resource oriented. After what will be on the network as a resource, it is the resource for each request operation, such as deletions of resources investigation changed.

What is the difference between SOAP WS and RESTful Web Service?

 

  • SOAP WS supports both remote procedure calls (for example, RPC) and supports messaging middleware (MOM) approach to application integration. And Restful Web Service supports only the RPC in an integrated manner.
  • SOAP WS is transport protocol independent. It supports multiple protocols, such as, HTTP (S), Messaging, TCP, UDP SMTP, and so on. The REST protocol is relevant, only supports HTTP or HTTPS protocol.
  • SOAP WS only allows the use of XML data format. Operation defined by the POST request. The focus is acquired by the operation of the service name, and the application logic as services. REST manner and allows a variety of data formats, e.g., XML, JSON, text, HTML, and the like. And because the standard way of REST GET, PUT, PSOT and DELETE methods, so all browsers can support. The focus is to get the service through the resource name, and the data is encapsulated as services. AJAX support REST way, it can use the XMLHttpRequest object. Stateless CRUD operations (create, read, update and delete) more suitable in this way.

GET – represent()

POST – acceptRepresention()

PUT – storeRepresention()

DELETE – removeRepresention()

  • SOAP content can not be cached mode read. The REST approach is possible, and the performance and scalability are better.
  • SOAP WS supports SSL and WS-security, enterprise-class applications can have more security, for example, to enhance the safety index on demand, through a third party to ensure the security of identity authentication information, in addition to point-SSL (point to point SSL ), the more different parts of the message to provide different security algorithm and the like. The REST only support point to point SSL. And whether it is not sensitive information, SSL will encrypt the entire message.
  • For ACID SOAP-based short-lived and long-lived transaction management Transaction-based compensation transaction management depth support. Meanwhile, SOAP also supports distributed transactions (Translator: involving multiple resource managers in a distributed transaction environment) two-phase commit (two-phase commit) mode. And because the REST-based HTTP protocol, and therefore neither for transaction processing ACID-compliant manner does not provide two-phase commit distributed transactions mode.
  • Even through the third-party programs SOAP, SOAP built-in retry logic may also be provided end to end reliability. REST is not a standard messaging system, so customers even hopes to solve the problem by re-communication failure.

 How to choose which Web service adoption? SOAP WS or REST?

In general, REST-based Web service's advantage lies in its simplicity, good performance, scalability, and also supports a variety of data formats. The SOAP is applicable to the security and transaction processing requiring high reliability in service.

Consideration based on the requirements of designers of functional and non-functional requirements:

  • Service offerings exposure data or business logic it? (If so, then the data may be selected exposure mode REST, if exposed, then the business logic may select SOAP WS). The customer or service providers need a formal contract (contract) it? (SOAP can provide a formal contract through WSDL (Web Service Description Language))
  • You need to support multiple data formats do?
  • The need for an AJAX call it? (REST can be used to send AJAX XMLHttpRequest calls)
  • Synchronous or asynchronous invocation call?
  • Call stateful or stateless call? (REST CRUD operations for stateless)
  • For security requirements? (SOAP WS support for better security)
  • For transaction processing requirements? (SOAP WS advantage in this regard)
  • There is a bandwidth limit? (SOAP message redundancy Comparison)
  • Which way is more suitable for developers to do it? (REST better implementation and better testing and maintenance)

 

Webservice common framework, they have what characteristics?

Webservice common framework JWS, Axis2, XFire and CXF (JAX-WS).

1, JWS is a Java an implementation language for WebService services for developing and publishing services. And from the point of view of the service itself JWS service is no language boundaries. But the Java language provides a convenient way to publish and invoke WebService services for Java developers.
2, Axis2 WebService framework is a heavyweight in the Apache, it is exactly a Web Services / SOAP / WSDL engine, a master of WebService framework, it can not only create and publish WebService, and can generate Java and other languages Version WebService client and server code. This is its advantage. However, this inevitably leads to the complexity of Axis2, used the developers know, it depends on the number and size of the package is very alarming, deployment package release is too much trouble, not well with the existing application integration as a whole. But if you want to develop language other than Java client, providing rich tools Axis2 will be your only choice.
3, XFire is a high-performance WebService framework before Java6, it's more famous than the Apache Axis2, XFire is to develop the advantages of convenient, well integrated with existing Web can be integrated, and development is also very Convenience. But a language other than Java, the code does not provide relevant tools. XFire Apache was later acquired, because it is too good, after the acquisition, with the rise of Java6 JWS, open source is no longer optimistic about the WebService engine, gradually are spoiled.
4, CXF is a blockbuster of Apache's simple SOA framework, which implements the ESB (Enterprise Service Bus). CXF from XFire project, formed after the transformation, as is currently the Struts2 from WebWork same. It can be seen XFire fate and destiny would like WebWork will eventually fade out of sight. CXF is not only an excellent Web Services / SOAP / WSDL engine, is also a good bus ESB provides an option for the implementation of SOA, of course, he is not the best, it only implements SOA architecture part of.
Note: For the relationship between the Axis2 and CXF, a time appeared earlier Axis2, CXF and fast catch-up speed.

How to choose: 
1, if the application needs to support multiple languages, Axis2 should be the first choice;
2, if the application is to follow the  spring philosophical line, then, Apache CXF is a better choice, especially for embedded Web Services to say;
3, if the application does not need new features, then it is still using the original framework used by the project, such as Axis1, XFire, Celtrix or BEA's Web Services and so on their own to achieve, do not waste money up.

JAX-RS support service specification framework are:

1.CXF - merger of Celtix and XFire 

2.Jersey - Sun's JAX-RS reference implementation.

3.RESTEasy - JBoss's JAX-RS project. 

4.Restlet-- probably the first REST framework, and there before it JAX-RS.

WebService two common realization: CXF and Axis2

Details, see: Web Service works and examples

 

CXF framework for the development of RESTful WebService example: the difference between the web service and RESTful WebService

Examples jersey: The use Java to create RESTful Web Service

https://www.jianshu.com/p/2fc9f900c1e4

Guess you like

Origin blog.csdn.net/qq_23018459/article/details/90609468