Defining Web Services with WSDL

Source: Internet
Author: User
Tags format define object definition interface soap web services wsdl
Web|web Service


In the world of Web services, applications are largely made up of remote, XML-driven components that are written in different languages and are connected through the Web using standard remote activation protocols. The service provider defines the data format that is required for the service provided. Similarly, when you accept Web services in the above application mode, you also need to take steps to ensure that your client program uses the data format that the server expects. This is where the WSDL (Web Service Definition Language) is the place to be.

WSDL Overview
WSDL is a standard XML format for describing XML Web services, and WSDL is presented by Ariba, Intel, IBM, and Microsoft. It defines the actions and messages sent and received by a given Web service in an abstract way that is not specific to language. As a definition, you cannot use WSDL as an Object interface definition language, for example, application architectures such as CORBA or COM are used for object interface definition languages. WSDL remains protocol neutral, but it does have built-in support for binding soap, thus creating an inextricable link with soap. So, when I discuss WSDL in this article, I assume that you have soap as your communication protocol.



The WSDL protocol has been submitted to the Internet Standards Organization's consortium for approval and is currently in the "Confirm submit" state. The consortium maintains a formal system of standardization and submits a set of approval processes that must be finalized in order to eventually become an official agreement. In this case, the status of the WSDL, in layman's view, at least the standard organization is considering making it part of possible future standards. If you're interested in the situation, or if you happen to be a "insomnia patient" with a specific concern, you may want to go to the Web site and read the recommended standards.

Describing services with WSDL
As an xml-based standard, if you have a certain understanding of XML, then the structure of the WSDL will not be unfamiliar to you. A WSDL document consists of a set of elements that a service uses to describe a data type, a "message" that a service can receive, and a SOAP binding that associates each message.



Listing A is a simple WSDL document that is the same as the WSDL demo text published by the Web site, which illustrates a stock quotes service (which is also a fairly standard Web service).



If you look at listing a again, you can see that the document begins with a standard XML header, which contains a version ID, and the root element of the document is called definitions.



The definitions element can take several optional properties that describe the namespace (namespace) that the document uses to define the remainder of the document. In this case, the definition is assigned a name (StockQuote), and some namespace definitions are based on the following general prefix abbreviations:

tns-"This namespace", containing the primary namespace of the defined service
Xsdl-xml Schema (XSD) namespace, for defining types in documents
Namespace used by Soap-soap bindings
Next, in order to define the interface of a service, you need to define any complex types that you need within the type element. Here you must pay attention to the use of standard XSD syntax (attributes), which is the most appropriate way to create a data type definition. However, if you wish, WSDL can also extend the use of different types of definition systems.

Message Overview
In the use of WSDL, a message can be any parameter that is passed to a method on a service advertisement object or any return result after the method is invoked. In order to continue using the stock quotes this Web service example, a single definition approach is likely to be as shown in the following pseudocode:

Floatgetlasttradeprice (String tickersymbol)

So, as you can see from listing a, there are two messages defined in the document, An input parameter Tickersymbol (Getlasttradepriceinput message) representing the method another represents the return value (Getlasttradepriceresult message) of the method-the latest stock price.



The operation organizes the messages together and represents the method definition abstractly. In our case, both messages are organized in the Getlasttradeprice object method definition under the Getlasttradeprice action element. All operations in a WSDL file are grouped together within the porttype element.



The remainder of the WSDL document binds the message with the listening endpoint (binding element) on the server and combines the port definition with a single service entity (the service element). The example in listing a defines the bindings required to adopt a service through SOAP.

WSDL tool
You can create WSDL files by hand, but you can also use a lot of tools to automate the process and definition of Web services for you through WSDL. The recommended tool software is as follows:

omniopera-WSDL, XML, and XSD editors for a graphical user interface
Microsoft SOAP toolkit-A toolkit that includes wizards that create COM interfaces based on WSDL definitions, and wizards that create WSDL from COM interfaces
IBM Web Services toolkit-A toolkit that includes wizards that generate WSDL and SOAP deployment instructions



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.