[WS] A simple WSDL document (I)

Source: Internet
Author: User
Tags define abstract

Now, let's briefly explain the content and structure of the WSDL document corresponding to the Web Service published in "Publish simple web service with axis. Note that the WSDL documents obtained from the same Java classes in different Web Service Development Kits are not necessarily the same. Here we use axis as an example.

Although it is relatively long, the complete WSDL should be pasted below for convenience and then explained. Because I do not have enough understanding of Web Services, there may be some misunderstandings, just for reference.

 <?  XML version = "1.0" encoding = "UTF-8"  ?>  <  WSDL: Definitions  Targetnamespace  = "Http: // localhost: 8080/bookstore/services/booksvc"  Xmlns  = "Http://schemas.xmlsoap.org/wsdl"  Xmlns: apachesoap = "Http://xml.apache.org/xml-soap"  Xmlns: impl  = "Http: // localhost: 8080/bookstore/services/booksvc"  Xmlns: INTF  = "Http: // localhost: 8080/bookstore/services/booksvc"  Xmlns: soapenc  = "Http://schemas.xmlsoap.org/soap/encoding"  Xmlns: tns1  = "Http://model.bookstore.com"  Xmlns: WSDL  = "Http://schemas.xmlsoap.org/wsdl"  Xmlns: wsdlsoap = "Http://schemas.xmlsoap.org/wsdl/soap"  Xmlns: XSD  = "Http://www.w3.org/2001/XMLSchema"  >    <  WSDL: Types  >      <  Schema  Targetnamespace  = "Http://model.bookstore.com"  Xmlns  = "Http://www.w3.org/2001/XMLSchema"  >        < Import  Namespace  = "Http://schemas.xmlsoap.org/soap/encoding"  />        <  Complextype  Name  = "Book"  >          <  Sequence  >            <  Element  Name  = "ISDN" Nillable  = "True"  Type  = "XSD: string"  />            <  Element  Name  = "Name"  Nillable  = "True"  Type  = "XSD: string"  />            <  Element  Name = "Page"  Type  = "XSD: int"  />          </  Sequence  >        </  Complextype  >      </  Schema  >    </  WSDL: Types  >    < WSDL: Message  Name  = "Addbookresponse"  >    </  WSDL: Message  >    <  WSDL: Message  Name  = "Addbookrequest"  >      <  WSDL: Part  Name  = "Book" Type  = "Tns1: Book"  />    </  WSDL: Message  >    <  WSDL: porttype  Name  = "Booksvc"  >      <  WSDL: Operation  Name  = "Addbook"  Parameterorder = "Book"  >        <  WSDL: Input  Message  = "INTF: addbookrequest"  Name  = "Addbookrequest"  />        <  WSDL: Output  Message  = "INTF: addbookresponse"  Name  = "Addbookresponse"  />     </  WSDL: Operation  >    </  WSDL: porttype  >    <  WSDL: Binding  Name  = "Booksvcsoapbinding"  Type  = "INTF: booksvc"  >      <  Wsdlsoap: Binding  Style = "RPC"  Transport  = "Http://schemas.xmlsoap.org/soap/http"  />      <  WSDL: Operation  Name  = "Addbook"  >        <  Wsdlsoap: Operation  Soapaction  = ""  />        <  WSDL: Input Name  = "Addbookrequest"  >          <  Wsdlsoap: Body  Encodingstyle  = "Http://schemas.xmlsoap.org/soap/encoding"  Namespace  = "Http://bookstore.com"  Use  = "Encoded"  />        </  WSDL: Input  >        < WSDL: Output  Name  = "Addbookresponse"  >          <  Wsdlsoap: Body  Encodingstyle  = "Http://schemas.xmlsoap.org/soap/encoding"  Namespace  = "Http: // localhost: 8080/bookstore/services/booksvc"  Use  = "Encoded"  />        </  WSDL: Output >      </  WSDL: Operation  >    </  WSDL: Binding  >    <  WSDL: Service  Name  = "Booksvcservice"  >      <  WSDL: Port  Binding  = "INTF: booksvcsoapbinding" Name  = "Booksvc"  >        <  Wsdlsoap: Address  Location  = "Http: // localhost: 8080/bookstore/services/booksvc"  />      </  WSDL: Port  >    </  WSDL: Service  >  </  WSDL: Definitions > 

The root element of each WSDL is <definitions>. Generally, various namespaces in the document are defined here. For the WSDL above, many namespaces are defined, and their functions are described now.

We all know that WSDL should be a correctly formatted XML document. Furthermore, we should regard it as a schema. Therefore, the <definitions> element can define the targetnamespace attribute, indicating that all elements under this element belong to this target namespace.

Xmlns indicates the default namespace. Note that in the document above, the value of this default namespace is the same as the value of xmlns: WSDL (both http://schemas.xmlsoap.org/wsdl ). Therefore, many <WSDL: XXX> elements in the WSDL, such as <WSDL: types> and <WSDL: porttype>, are omitted: "The effect is the same.

Namespace xmlns: apachesoap is not used in the document. This should be a namespace reserved by axis for some situations, or used to be compatible with previous versions, because axis is a predecessor of the Apache SOAP project.

The namespace xmlns: INTF and xmlns: impl represent interfaces and implementations respectively. We can see that their values are the same and they are consistent with the targetnamespace of <definitions>. This is used to reference the defined elements in the target namespace in the document. For example, "<WSDL: Binding name =" booksvcsoapbinding "type =" INTF: booksvc "> ", the booksvc must be defined in a previous element and belongs to the target namespace specified in <definitions>. It makes sense for axis to separate INTF from impl, because in many cases, a wsdl will reference another WSDL, the latter may only define abstract elements such as data types, messages, and port types, while the former defines implementation-related content such as binding and service ports. We will not discuss it here.

Namespace xmlns: soapenc is not used in this document, so I will not explain it first.

Namespace xmlns: tns1. In many WSDL, this name is called TNS, and there is no following number 1. Why does it start with Axis. But it doesn't matter. The namespace name has no actual meaning, but it is just a code name. TNS is the abbreviation of this namespace. It is used to reference the current WSDL. Since a WSDL maps a package, in the WSDL that axis generates for us, the tns1 value (http://model.bookstore.com) contains the Java package (COM. bookstore. model. Note that the value of tns1 is the same as the targetnamespace value of the <schema> element in <WSDL: types>.

Namespace xmlns: wsdlsoap is used when it is bound to soap, such as <wsdlsoap: Binding>, <wsdlsoap: Operation> and other elements.

Namespace xmlns: XSD is a reference to various data types in XML schema, such as string and Boolean. To know which data types are defined in XML schema, you just need to view the value of the namespace (http://www.w3.org/2000/10/XMLSchema.

I didn't expect that there was so much writing in the namespace, and there was still a lot of content in the WSDL structure, so I should divide it into two parts. The next article will talk about the role of each element in the WSDL.

References:

    • Web Services Description Language (whitelist) 1.1
    • Basic knowledge of defining elements using XML Schema
    • Use axis to publish simple Web Services

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.