JAVA language (advanced tutorial): What is WebService?
Source: Internet
Author: User
JAVA language advanced: What is WebService-general Linux technology-Linux programming and kernel information, the following is a detailed description. You may have heard of Web Services for a long time, and you may already have some concepts about Web Services. For a time, it seems that all computer journals, books, and websites are beginning to mention Web Services. However, most of the current Web service introductions do not clearly explain what the Web service is. They only advocate how good Web services are, just like advertising. In this article, I will explain two things: What is Web service and under what circumstances should you use Web service.
Distributed applications and browsers
Looking at the current application development, you will find an absolute tendency: people begin to prefer browser-based thin client applications. This is not because thin customers can provide better user interfaces, but because it can avoid high costs for desktop application Publishing. The cost for publishing desktop applications is high, half because of application installation and configuration problems, and the other half because of communication between the customer and the server.
Traditional Windows Rich Client Applications Use DCOM to communicate with servers and call remote objects. Configuring DCOM to work properly on a large network is a challenging task and a nightmare for many IT engineers. In fact, many IT engineers prefer to endure the functional limitations imposed by browsers and do not want to run a DCOM on the LAN. In my opinion, the result is an application that is easy to publish but difficult to develop and has extremely limited user interfaces. To put it bluntly, you spend more money and time developing applications with weaker functionality from the user's perspective. Believe it? Ask your accountant what he thinks about the new browser-based accounting software: most commercial users want to use a more friendly Windows user interface.
A perfect solution for communication between the client and the server is to use HTTP protocol. This is because any machine running a Web browser is using the HTTP protocol. At the same time, many firewalls are configured to only allow HTTP connections.
Many commercial applications face another problem: interoperability with other programs. If all applications are written in the COM or. NET language and run on the Windows platform, the world is too peaceful. However, in fact, most commercial data is still stored on large hosts in the form of non-relational files (VSAM) and accessed by mainframe programs written in the COBOL language. In addition, there are still many commercial programs that are still using C ++, Java, and Visual
Basic and other languages. Now, except for the simplest program, all applications need to be integrated with applications running on other heterogeneous platforms for data exchange. Such tasks are usually performed by special methods, such as file transfer and analysis, message queues, and APIs that only apply to certain situations, such as IBM's "advanced program-to-program communication (APPC). In the past, there was no application communication standard, which was independent of the platform, modeling, and programming language. Only through Web
Service, the client and server can communicate freely with HTTP, regardless of the platform and programming language of the two programs.
What is Web Service?
We have at least two answers to this question. On the surface, Web service is an application that exposes an API that can be called through the Web. That is to say, you can use a programming method to call this application through the Web. We call the Web service application a customer. For example, if you want to create a Web service, its function is to return the current weather conditions. You can create an ASP page that accepts the zip code as a query string and returns a string separated by commas (,), containing the current temperature and weather. To call this ASP page, the client needs to send the following http get request:
This ASP page can be regarded as a Web service. Because it is based on http get requests, it exposes an API that can be called through the Web. Of course, there are more Web services.
The following is a more accurate explanation of Web services: Web services is a new platform for building interoperable distributed applications. As a Windows programmer, you may have created a component-based distributed application using COM or DCOM. COM is a very good component technology, but we can easily cite situations where COM does not meet the requirements.
The Web service platform is a set of standards that define how applications implement interoperability on the Web. You can use any language you like to write Web Services on any platform you like, as long as we can query and access these services through Web service standards.
New Platform
The Web service Platform requires a set of protocols to create distributed applications. Any platform has its Data Representation Method and type system. To achieve interoperability, the Web service platform must provide a standard type system for communicating different types of systems in different platforms, programming languages, and component models. In traditional distributed systems, interfaces-based platforms provide methods to describe interfaces, methods, and parameters (such as the IDL Language in COM and COBAR ). Similarly, the Web service platform must provide a standard to describe the Web service, so that the customer can obtain sufficient information to call this Web service.
Service. Finally, we must have a way to remotely call this Web service. This method is actually a Remote Procedure Call Protocol (RPC ). To achieve interoperability, this RPC protocol must also be independent of the platform and programming language. The following sections briefly describe the three technologies that constitute the Web service platform.
XML and XSD
The Extensible Markup Language (XML) is the basic format for data representation on the Web service platform. In addition to ease of establishment and analysis, XML has the primary advantage of being platform-independent and vendor-independent. Independence is more important than technical superiority: software vendors will not choose a technology invented by competitors.
XML solves the problem of data representation, but it does not define a set of standard data types, let alone how to extend this set of data types. For example, what is the integer number? 16-bit, 32-bit, or 64-bit? These details are important for implementing interoperability. XML Schema (XSD) developed by W3C is a set of standards dedicated to solving this problem. It defines a set of standard data types and provides a language to extend this data type. The Web service platform uses XSD as its data type system. When you use a language (such as VB. NET or C #) to construct a Web service, to comply with the Web service standard, all the data types you use must be converted to the XSD type. The tool you use may have automatically completed the conversion, but you may modify the conversion process as needed. In chapter 2, we will go deep into XSD and learn how to convert Custom Data Types (such as classes) to XSD types.
SOAP
After the Web service is created, you or others will call it. Simple Object Access Protocol (SOAP) provides standard RPC methods to call Web Services. In fact, SOAP is a bit inappropriate here: it means that the following Web service is represented in the form of an object, but this is not necessarily the case: you can write your Web service as a series of C functions and still use SOAP for calling. The SOAP specification defines the format of SOAP messages and how to use SOAP over HTTP. SOAP is also based on XML and XSD, and XML is the data encoding method of SOAP. In chapter 3, we will discuss SOAP and understand the various elements of SOAP messages.
WSDL
How do you introduce to others the functions of your Web service and the parameters for each function call? You may write a set of documents on your own. You may even verbally tell people who need your Web service. These informal methods have at least one serious problem: when programmers sit in front of a computer and want to use your Web service, their tools (such as Visual Studio) they cannot provide any help, because these tools do not know your Web
Service. The solution is to provide a formal description document that can be read by machines. The Web service Description Language (WSDL) is an XML-based language used to describe Web services and their functions, parameters, and returned values. Because it is based on XML, WSDL is both readable and readable, which is a great benefit. Some of the latest development tools can generate a WSDL document based on your Web service, and import the WSDL document to generate code that calls the corresponding Web service.
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.