Webservcie "Turn"

Source: Internet
Author: User
Tags wsdl

What the hell is WebService?

Word:WebService is a remote invocation technique across programming languages and cross-operating system platforms.

Web Service is a platform-independent, low-coupling, self-contained, programmable Web-based application that uses Open XML (a subset of standard common markup languages) to describe, publish, discover, orchestrate, and configure these applications for the development of distributed, interoperable applications. WEB Service technology enables different applications running on different machines without the use of additional, specialized third-party software or hardware, which canexchanging data or integration with each other。 Applications that are implemented according to the Web Service specification can exchange data with each other, regardless of the language, platform, or internal protocol they are using. Web service is a self-describing, self-contained, available network module that can perform specific business functions. Web service is also easy to deploy because they are based on some common industry standards and some of the technologies that are available, such as subset XML, HTTP, in standard generic markup language. Web service reduces the cost of application interfaces. WEB Service provides a common mechanism for integration of business processes across the enterprise and even across multiple organizations.

The WebService platform requires a set of protocols for the creation of distributed applications. Any platform has its own data representation method and type system . To achieve interoperability, the WebService platform must provide a standard set of type systems for communicating different types of systems in different platforms, programming languages, and component models. The Web service platform must provide a standard to describe the Web service, giving the customer enough information to invoke the Web service. Finally, there must be a way to make a remote call to the Web service, which is actually a remote procedure call Protocol (RPC). To achieve interoperability, this RPC protocol must also be independent of the platform and programming language.

Third, WebService platform technology

Xml+xsd,soap and WSDL are the three major technologies that make up the WebService platform.

Xml+xsd:

WebService transmits data using the HTTP protocol, encapsulating the data in XML format (that is, what method of invoking the remote service object in XML, what parameters are passed, and what the service object returns). XML is the format for representing data in the WebService platform. In addition to being easy to establish and easy to analyze, the main advantage of XML is that it is platform-independent and vendor-independent. Independence is more important than technical superiority: Software vendors do 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, much less how to extend this set of data types. For example, what does shaping number mean? 16-bit, 32-bit, 64-bit? These details are important for interoperability. XML Schema (XSD) is a set of standards specifically designed to address this problem. It defines a standard set of data types and gives a language to extend this set of data types. The WebService platform uses XSD as its data type system. When you construct a Web service in a language such as vb.net or C #, all data types that you use must be converted to an XSD type in order to conform to the WebService standard. The tool you used may have automatically helped you with the conversion, but you will probably have to modify the conversion process to suit your needs.

Soap:

WebService sends requests and receives results through the HTTP protocol, both the requested content and the resulting content are encapsulated in XML format, and some specific HTTP message headers are added to describe the content format of the HTTP message. These specific HTTP message headers and XML content formats are the SOAP protocol. SOAP provides a standard RPC method to invoke a Web Service.

SOAP protocol = HTTP protocol + XML data format

The SOAP protocol defines the format of the SOAP message, the SOAP protocol is based on the HTTP protocol, and SOAP is based on XML and XSD, and XML is the data encoding method of soap. A metaphor: HTTP is the normal highway, XML is the middle of the green barrier and both sides of the fence, soap is the ordinary highway through the belt and the fence has been modified highway.

Wsdl:

Like we go to the store to buy things, first of all, we have to know what is in the store to buy, and then to buy, the way the merchant is to put up advertising posters. WebService also, the WebService client to invoke a WebService service, first of all have to know the address of the service where, and what the method can be called in this service, so, The WebService server is the first to use a WSDL file to explain what services in their home can be called externally, what the service is (what methods are available in the service, what parameters are accepted by the method, what the return value is), which URL address the service's network address is represented by, and how the service is invoked.

WSDL (web Services Description Language) is an XML-based language that describes a WEB service and its functions, parameters, and return values. It is a standard format that can be understood by both the WebService client and server side. Because it is XML-based, WSDL is both machine readable and human readable, which is a great benefit. Some of the latest development tools can generate WSDL documents based on your Web service, import WSDL documents, and generate proxy class code that calls the appropriate webservice.

The WSDL file is saved on the Web server and can be accessed through a URL address. Before the client wants to invoke a WebService service, it needs to know the address of the WSDL file for the service. The WebService service provider can expose its WSDL file address in two ways: 1. Register to a UDDI server for lookup; 2. Directly to the client caller.

Iv. Development of WebService

WebService development can be divided into two aspects of server-side development and client development:

Server-side development: The company's internal system of business methods published into WebService services for remote cooperation units and individuals to call. (Some webservice frameworks make it easy to publish your business objects as WebService services, typical Java WebService frameworks include: AXIS,XFIRE,CXF, Java EE servers often also support publishing webservice services, such as JBoss. )
Client development: Call the WebService service, which most people engage in, for example, call the weather WebService service. (Use tools such as the vendor's Wsdl2java to generate proxy class code for static calls, use vendor-supplied client programming API classes, use a JAX-RPC development package from the Sun Company's early standards, and use the JAX-WS development Package from Sun's latest standards.) Of course, Sun has been acquired by Oracle)

WebService's work invocation principle: For the client, we pass the URL address of the WSDL file to the various WebService client APIs, which create the underlying proxy class, and I can call these proxies to access the WebService service. The proxy class turns the client's method call into a SOAP-formatted request data and sends it through the HTTP protocol, returning the received SOAP data to the return value. For the service side, the essence of all kinds of WebService framework is a large servlet, when the remote call client to it through the HTTP protocol sent over the SOAP format of the request data, it analyzes the data, it will know which Java class to invoke which method, It then finds or creates the object, calls its method, wraps the result of the method back into SOAP-formatted data, and returns it to the client via an HTTP response message.

V. Applicable occasions

1. Cross-firewall communication:

If the application has thousands of users and is distributed around the world, then communication between the client and the server will be a tricky issue. Because there is usually a firewall or proxy server between the client and the server. In this case, the use of DCOM is not so simple, it is often not easy to publish the client program to a large number of each user. The traditional approach is to use a browser as a client, write down a lot of ASP pages, and expose the middle tier of the application to the end user. The result is that the development is difficult and the program is difficult to maintain. If the middle-tier component is replaced with WebService, the middle-tier component can be called directly from the user interface. From the experience of most people, in an application with more interaction between a user interface and the middle tier, using the WebService structure can save 20% of the development time spent on user interface programming.

2. Application integration:

Enterprise-Class application developers know that it is common for businesses to integrate various programs that are written in different languages and run on different platforms, and that this integration will take a lot of development power. Applications often need to get data from programs running on an IBM host, or send data to a host or UNIX application. Even on the same platform, a variety of software produced by different software vendors often need to be integrated. With WebService, it is easy to integrate applications with different architectures.

3, business-to-business integration:

Integration of applications with WebService enables more automated business processing within the company. But what happens when the deal crosses the boundaries of the supplier and the customer and breaks through the company? Cross-company business transaction integration is often referred to as a to-do integration. WebService is the key to the success of business-to-business integration. Through webservice, companies can "expose" critical business applications to designated suppliers and customers. For example, the electronic order system and the electronic invoice system "exposed", the customer can send orders electronically, the supplier can electronically send raw material purchase invoices. Of course, this is not a new concept, EDI (electronic document exchange) has been so long. However, the implementation of WebService is much simpler than EDI, and webservice runs on the internet and can be easily implemented anywhere in the world, with relatively low operating costs. However, WebService is not a complete solution for document exchange or business-to-business integration, as EDI does. WebService is just a key part of business-to-business integration, and many other parts are needed to achieve integration.

The biggest benefit of using WebService for business-to-business integration is the ease of interoperability. As long as the business logic is "exposed" and becomes webservice, it is possible for any designated partner to invoke these business logic, regardless of the platform on which their system runs, and what language to use. This greatly reduces the time and cost of spending on business-to-business integration, and enables many small and medium-sized enterprises that cannot afford EDI to achieve business-to-business integration.

4. Software and data reuse:

Software reuse is a big topic, the form of reuse is many, the degree of reuse is very small. The most basic form is the reuse of the source code module or class-level, and one form is the reuse of the component in binary form. Using the WebService application, you can "expose" functions and data in a standard way for use by other applications and to achieve business-level reuse.

Six, not applicable occasions

1. Stand-alone application:

Today, businesses and individuals are also using many desktop applications. Some of them only need to communicate with other programs on this computer. In this case, it is best not to use the WebService, just use the local API. COM is well suited to working in this situation because it is both small and fast. This is also true for server software running on the same server. It is best to use COM or other local APIs directly to make calls between applications. Of course webservice can also be used on these occasions, but that not only consumes too much, but does not bring any benefits.

2. Homogeneous Application of LAN:

In many applications, all programs are developed with VB or VC, all in the Windows platform using COM, all running on the same LAN. For example, there are two server applications that need to communicate with each other, or a WIN32 or WinForm client program that connects to another server on the LAN. In these programs, using DCOM is much more effective than soap/http. Similar to this, if one. NET program to connect to another. NET program on the LAN, you should use the. netremoting. Interestingly, in. Netremoting, you can also specify to use Soap/http to make webservice calls. However, it is best to make RPC calls directly over TCP, which is much more effective.

Webservcie "Turn"

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.