首页 > 应用开发 > IT综合 > Web Services 简介 (转)

Web Services 简介 (转)

原创 IT综合 作者:amyz 时间:2007-10-31 11:46:23 0 删除 编辑
Web Services 简介 (转)[@more@]

web Services 简介


In this column we embark on a new series on Web services. Web services are expected to revolutionize our life in much the same way as the Inte.NET has during the past decade or so. Web services provide a common protocol that Web applications can use to connect to each other over the Internet. The main advantage of Web services is that they are based on industry standards. The services are described in XML and are communicated over the existing HTTP infrastructure. The union of XML and HTTP forms one of the new industry buzz words: Simple object Access Protocol (SOAP). Publicizing Web services is done via two standards: Universal Description, DiSCOvery, and Integration (UDDI), and DISCO (abbreviation of Discovery). The big computer companies are betting on this new technology. They are developing platforms, tools, and kits to help build Web services.

You can write and call Web services in almost any language: VC++, C#, VB, Java, and Javascript. In upcoming columns, we will show you how to use our favorite language, JavaScript. In this column, we will describe Web services in general. We will show you what problems Web services are trying to solve, what the benefits are of using Web services, what's behind SOAP and UDDI, and what development tools microsoft, IBM, and Sun are promoting. We will show you where to find Web services on the Internet, and how to check their quality, before you try calling them. We'll end this column by explaining the structure and various elements of the Web service description file, written in the standard Web Service Description Language. We'll demonstrate WSDL with the Temperature-Weather Web service. This Web service accepts a message with your zip code, and returns the weather in your area.

2,Motivation behind Web Services
Bill Gates, in his leaflet to Developers & IT Professionals from June 14, 2001, covers the motivation for Web services, and the XML's role in this technology. We point out some of his arguments in this column.

Revolutions are a way of life in the computer industry. Only 20 years ago, the world was still in the mainframe era. Few people had access or used computers, and when they did, it was only through the nearest computer center. Three innovations changed all that: the PC, the GUI, and the Internet. Since then, standards such as HTML and HTTP have exponentially increased people's use of the Internet. This base protocol for viewing content on the Web (and the associated software for browsing this content) grew Web usage to what you are familiar with today. The Web became a key activity in the daily lives of businesses, employees, and consumers.

"Many of us envision an online world where constellations of PCs, servers, smart devices, and Internet-based services can collaborate seamleSSLy. Businesses will be able to share data, integrate their processes, and join forces to offer customized , comprehensive solutions to their customers. The information you or your business need will be available wherever you are, and whatever computing device, platform, or application you are using."

"That vision has yet to be achieved. In many respects, today's Internet still mirrors the old mainframe world. It's a server-centric computing model, with the browser playing the role of dumb teRminal. Much of the information you or your business needs is locked up in centralized databases, served up a page at a time to individual users. Web pages are simply a "picture" of the data, not the data itself, forcing many developers back to "screen scraping" to acquire information. Integrating that underlying data with your business's existing systems is a costly and frustrating challenge."

"Today's standalone applications and Web sites create islands of functionality and data. You have to navigate manually between Web sites, devices, and applications, logging in each time, and rarely being able to carry data with you. Tasks that ought to be simple, such as arranging a meeting with colleagues from partner companies and automatically updating every attendee's calendar, are a nightmare in the best case, and impossible in the common case. This inefficiency is a major source for productivity loss."

As a result of the changes in how businesses and consumers use the Web, the industry is converging on a new computing model that enables a standard way of building applications and processes to connect and Exchange information over the Web. This new Internet-based integration methodology, called "XML Web services," enables applications, machines, and business processes to work together in a revolutionary way. The widespread support around XML assures that businesses will cooperate in the Internet-based economy with this XML Web services model.

"At the heart of the solution is XML (eXtensible Markup Language). XML is an open industry standard managed by the World Wide Web Consortium. It enables developers to describe data being exchanged between PCs, smart devices, applications, and Web sites. Since the data is separate from the format and style definitions, it can be easily organized, programmed, edited, and exchanged between any Web sites, applications, and devices. Just as the Web revolutionized how users talk to applications, XML transforms how applications talk to each other."

Microsoft would like to convince us that Web services is the next revolution after the Web and HTTP. Judging from the Sun-Microsoft war on which Web services environment is better, Microsoft may be able to prove it.

3,Benefits of Web Services
Experts and visionaries believe that the benefits of XML Web services will be instrumental in propelling explosive business growth over the next few years. One of the major benefits is Web services' ease of integration. You will easily integrate your software with other pieces of software. You can run on all kinds of machines, from the desktop to the mainframe, either within your enterprise or at external sites. This ease of integration will enable tighter business relationships and more efficient business processes.

With Web services readily available, and as the pool of XML Web services grows, you will be able to find software modules that can be integrated into your own application, by finding it and integrating it through XML Web services. Integrate with existing Web services instead of reinventing them. The bottom line is that you will be able to develop applications much faster than before.

An integral part of the XML Web services programming model, is the ease of integration with external data sources. No longer does each application need to copy and maintain external data sources. You can request and get information in real time, and transfoRM it to your particular format. This will allow you to deliver individualized software and services, while your maintenance burden is reduced.

Consumers will enjoy ease of use when using XML Web services-based applications. XML Web services link applications, services, and devices together. Using Web services will be an integrated experience that excels in its simplicity. XML Web services give users the ability to act on information any time, any place, and from any smart device.

Businesses will love Web services because it will force them to streamline their processes. All suppliers will use the same language to describe their offerings. An XML Web service is a simple, reliable way to blend existing systems with new applications and services.

Microsoft is already sporting several commercial applications that were written in a record speed, thanks to the use of XML Web services. The first one is from Dollar Rent-A-Car. In two weeks, programmers built, tested, and deployed a Web Services-based solution that translates reservation requests and data between the company's mainframe-based reservation system and an airline partner's unix servers. Dollar can now reuse the same integration model to link their reservation system with other airline or hotel partners. The second case is This is a site that will find you the lowest price itinerary. They are now in the process of transforming itineraries into communication centers. These centers are Web services that users can access to get relevant and timely information at their convenience. With this new service, Expedia hopes to attract new customers and further strengthen the loyalty of their existing customer base.

You call Web services with messages that are written in the SOAP format. SOAP is a specification that defines the XML format for messages. A well-formed XML fragment enclosed in a couple of SOAP elements is a SOAP message. SOAP stands for Simple Object Access Protocol. You could print out a SOAP message, fax it to a remote location, and type it into the remote machine without violating the SOAP standard. More likely, you would send a SOAP message inside an HTTP message. There's no standard for how a SOAP message is carried, and SOAP doesn't care what the transport is. The SOAP specification defines what an HTTP message containing a SOAP message must look like.

The SOAP specification includes three major parts. The required part defines the structure of an XML document that can be used to exchange data between applications. Section 5 defines a way to encode programming language data types in XML. Such a message is called a section-5 encoded SOAP message. A regular message that contains an XML document is called a literal SOAP message. Section 7 of the SOAP definition is also optional. It deals with RPC (remote procedure calls), where the message is sent synchronously. You call a Web service's function and wait to check the return code. The default specification is for asynchronous call.

One of the critical principles of XML Web services is that systems connect through the Internet, which is a safe assumption. Internet connectivity is readily available and is provided with a very low cost to users of these Web services. The only problem is how to find these resources on the Internet. Will there be search engines? Directories? Some of the big computer companies such as Microsoft, Ariba, COMPAQ, Dell, HP, IBM, SAP, and others, are participating in a broad industry effort to define UDDI (Universal Description, Discovery, and Integration). UDDI provides a way to locate and understand services provided by other companies. It's a kind of "yellow pages" on the Internet for the industry.

5,Development Tools
With the momentum behind XML Web services growing among developers, computer companies are building platforms to help them write, deploy, use, and manage these services. Sun is promoting its Sun Open Net Environment (Sun ONE) for these purposes. Microsoft has its own platform, the .net (pronounced dotnet) platform. It contains both products and services developers need to build and run XML Web services. It also enables integration of XML Web services with other computers, smart devices, and other Web-based services. Because XML is an open standard, Microsft assures us that the products and services within Microsft .NET will interoperate with a broad set of XML- and XML Web services-enabled infrastructure and developer tools from other vendors.

Under the umbrella of the .NET environment, Microsoft is promoting two major tools: Visual Studio.NET and .NET framework. Visual Studio.NET is Microsoft's next generation multi-language development tool. It helps developers quickly build XML Web services and applications that scale easily, using the language of their choice. The supported languages are: Visual Basic, which includes new object-oriented programming features, Visual C++, which advances windows-based development and enables you to build .NET applications, and C#, which brings RAD (Rapid Application Development) to C and C++ developers. Other languages will be supported by third parties: perl, Python, COBOL, and Eiffel.

The .NET Framework is a high-productivity, standards-based, multi-language application execution environment that handles essential plumbing chores and eases deployment. The .NET Framework improves the reliability, scalability, and security of your application. It includes several parts: the Common Language Runtime, a rich set of class libraries for building XML Web services, and ASP.NET, the next generation Active Server Pages.

6,Writing WSDL
When planning to use a new Web service, you need to learn its interface first. You can learn it from the Web service's WSDL (Web Services Description Language) document. It describes the messages that the Web service understands, the format of its responses to those messages, the protocols that the service support, and so on. The WSDL document is easy to browse. Just click the lines beginning with the ("-") and plus ("+") signs, to contract or expand the code.The WSDL document can be divided into two groups: the Abstract Definitions Group and the Concrete Descriptions Group. The abstract sections define SOAP messages in a platform- and language-independent manner; they don't contain any machine- or language-specific elements. The concrete sections are site-specific, machine-specific, or language-specific. The abstract elements are types, message, and portType. The concrete elements are binding and service.

The root of any service description file is the element. The elements includes the namespace definitions. In the Weather - Temperature Web service, it looks like this:


The types element contains datatype definitions. Usually, this element includes a schema element that defines various datatypes. Here is a complexType element definition from the interopTest Web service's types element:" targetNamespace="">





The message element describes the data being exchanged between the Web service providers and consumers. Each Web method has two messages: input and output. The input describes the parameters for the Web method; the output describes the return data from the Web method. Each message contains zero or more parameters, one for each parameter of the Web method. Each parameter associates with a concrete type defined in the container element. In the Temperature - Weather Web service, the input parameter is a string-typed zip code. Here is how the element is defined:


The portType element includes a supported set of operations. Each operation includes the input and the output messages of the operation. Here is the getTemp operation from the Temperature - Weather Web service:


Each binding element describes a supported protocol. Similar to the portType element, the binding element includes supported operations, as well as the input and output for each operation. Here is the binding element from the Temperature - Weather Web service:" />
    encodingStyle="" />
    encodingStyle="" />


The service element is a collection of ports. Each port supports a different protocol. Here is a SOAP port from the Temperature -- Weather Web service:

  Returns current temperature in a given U.S. zipcode" />

7,A Final Word
In this column we embarked on a new series on Web services. We introduced you to the concept, the motivation behind them, and the benefits you are expected to get from them. We explained several basic terms, such as SOAP, XML, UDDI, and WSDL. We pointed out to you two directories where you can find hundreds of readily-available Web services. Using a Web service necessitates a careful screening of candidates. One criterion to judge by is the Web service's quality, and adherence to its specification. Luckily, there are Web sites that check the interoperability between Web services. We showed you a way to check if the recent regression suite passed or failed. The Web Service Description Language (WSDL) is used to describe the service's interface. We listed the description file of a Web service that returns the weather in a given zip-code area. We went over the WSDL's abstract and concrete definitions.





来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

  • 博文量
  • 访问量