[WS] A simple WSDL document (below)

Source: Internet
Author: User

Although the published service is simple, the WSDL document generated by Axis seems complicated. The main reason for this is that WSDL must be compatible with various implementations and be scalable, this is like if we use some frameworks for developmentCodeThe advantage is that the logic is clearer. The upper part of this post describes the namespaces commonly used in WSDL. Now let's talk about the meaning of each element in WSDL.

A wsdl document generally contains <types>, <message>, <porttype>, <binding>, and <service> elements, <types>, <message>, and <porttype> can be considered as abstract interface definitions, while <binding> and <service> are specific implementations. Note: in some cases, <binding> is also considered as a part of the interface. You may have seen some cases where WSDL writes these two parts separately in Two XML files and introduces (import) Another one in one file, this is one of the reasons for distinguishing between interfaces and implementations. In the real world, some interfaces may be formulated by an organization (such as an industry association). Members of this Organization must introduce them when releasing their own Web Services, to achieve the goal of unified standards.

<Types> tags are used to define custom data types other than the data types defined in XML Schema. For custom classes (books ), it corresponds to a <complextype>, where the <element> element is used to specify the type of each parameter. The JAX-RPC specification specifies the ing of the Data Type of the Java language to the XML schema data type, such as int <-> XSD: int, Java. lang. string <-> XSD: string and so on, as well as the array ing method.

<Message> A tag defines a message in a web service. The most common is a request and Response Message. <Message> can contain <part> elements, which correspond to the parameters or return values of each method in the Java class. For example, the addbook () method has a book-type parameter, the description of <part name = "book" type = "tns1: Book"/> is displayed in the WSDL.

<Porttype> the label indicates the type of a service, which is the meaning of the interface. Some concepts in WSDL are very confusing. For example, the difference between port and service means that a service has a specific URL, and port represents an address. porttype is the abstraction of the service, I don't know, right. Let's take a look at a WSDL document. Generally, we should first look for the <porttype> element to see which methods are used in the Web service represented by this WSDL, and what their parameters and return values are. These methods are represented by <operation> elements in <porttype>. <operation> <input> and <output> sub-elements can be included to represent the input and output of methods. Note that the method can only be input or output.

<Binding> the element binds the porttype to a specific transport protocol. At present, most of them are bound to soap. For each method input and output, you must specify the soap representation method. The JAX-RPC specification specifies that soap binding can have RPC and document types, indicating Remote Procedure Calls and message-based methods, respectively. The use attribute can be encoded or literal. For the former, RPC is supported, and for the latter, RPC and document are supported. They make the SOAP message format different, but I haven't studied it carefully, you can refer to section 1.1-6.3 of JAX-RPC 6.4. Another question arises: what is the relationship between soap and HTTP? Is binding to soap equivalent to binding to HTTP? Shouldn't it be, so where can I specify the application layer protocol (HTTP, SMTP, and so on) bound to the Web service? (Update: the application layer protocol specified by the Transport attribute)

Finally, the <service> element uses the <port> sub-element to link the service to a specific URL. To be more precise, it is necessary to associate a bound porttype with a specific URL, in this way, you will know which server to send the SOAP message.

I think it takes a lot of time to understand WSDL, because WSDL plays a core role in the entire web service, it is a complete syntax description of Web Services, and is closely related to XML, SOAP, and UDDI, therefore, it is important for us to better understand the Web service architecture. Although the current web service development tools can automatically perform Java <-> WSDL conversion, it is necessary to understand whether the Web service is designed, developed, modified, and debugged.

References:

    • Web Services Description Language (whitelist) 1.1
    • Use axis to publish simple Web Services
    • A simple WSDL document (I)

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.