Customizing Web Service behavior with the JAXB framework

Source: Internet
Author: User
Tags data structures soap web services hosting java web wsdl

WEB Services

WEB Services Overview

In essence, Web services are externally exposed and can be invoked through the web of a set of APIs, it does not require the service provider and the caller's technical implementation, programming language, running platform and even operating system. It is also because of this feature Web services can quickly occupy a niche in enterprise application integration, and become one of the preferred means of implementing application integration, while Web services is also an important implementation tool for service-oriented architectures.

Deep analysis of Web services It's not hard to find out that there are several issues behind this simple definition: how the Web Service provider describes itself to be understood by the caller, how the caller discovers the available Web services, and how the caller should invoke the specific interface after it finds the Web service that is needed. The industry already has a number of standards and protocols to address these issues and support the use of WEB services, including the most important non-WSDL, SOAP, UDDI. This article takes a Java Web service as an example to describe how to customize behavior.

WEB Services Basic Artifacts

WSDL, SOAP, and UDDI are the most basic and important components of Web services, and these three protocols define the description, discovery, and access of Web services.

WSDL (Web service Description Language): Web Services Description Language. Each WEB service will have a corresponding WSDL document to describe. The WSDL document first abstracts the interface and the request/response message at the time of access, and then binds it to the specific transport protocol and message format to ultimately define the service access point for the specific deployment. The WSDL document is essentially an XML-formatted document that details the set of interfaces exposed by WEB services, interface prototypes, interface parameters, data structures for return types, interface invocation message formats, hosting protocols, and so on.

SOAP (Simple Object access Protocol): An easy objects Access protocol. The SOAP protocol is essentially a combination of XML and HTTP protocols that defines an XML-formatted WEB service access message Encapsulation format and message hosting via HTTP protocol, and of course SOAP messages can also be hosted via protocols such as HTTPS or SMTP.

UDDI (Universal Description, Discovery and Integration): Unified description, Discovery, and integration protocols. It is a technical standard designed to address issues of publishing and discovery of Web services, including a set of implementation standards for a web-based, distributed Web Services Information registry, and a set of implementation standards that enable organizations to register their own Web services to the center.

Data binding in a WEB service

In layman's terms, the transformation of XML form data and application business data structures is called data binding. XML can be used to describe Web services with its unique platform independence, but the core of Web services is still the application business logic processing, the business data structure needed in business logic processing rather than the XML format data, so data binding is required to complete the XML Format data to the application business data structure conversion. It is easy to see from the previous section that WEB services are represented in XML in the communication process, while in the Java Web Service provider and caller side are in the form of Java objects, so there is a need for a two-way transformation between XML and Java, which is the transformation process of XML and Java data binding. At present, there are many data binding implementations in the industry, such as ADB, XMLBeans, Jibx, Jaxme, JAXB, etc., which can be selected according to the actual situation of the project, like the AXIS2 is the use of their own ADB binding framework, and JAX-RPC type WEB services have their own binding mechanism. The following illustration visually reflects the data binding in the Java Web service invocation process:

Figure 1. Data-bound Web service types in Web services: JAX-WS vs Jax-RPC

The JAX-RPC specification defines how to implement WEB services using the Java language, which is java-based RPC, does not fully support XML schema specifications, and does not have a standard implementation of data binding definitions. JAX-WS is a follow-on version of Jax-RPC, which has been greatly improved and optimized in terms of protocol support, interface mapping model, and message transmission. At the same time Jax-ws is mapped to the Java 5.0 version, which uses a large number of Java 5.0 versions of new features such as annotations, generics support, and Jax-RPC maps to the Java 1.4 version. Another important difference is that jax-ws the data binding to JAXB, and Jax-RPC, as mentioned earlier, defines a nonstandard private binding mechanism that directly leads to the difficulty of customizing data binding to Web services in a JAX-RPC Web service. The Web services referred to later in this article default to JAX-WS Web services.

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.