WSDL file example
Let's take a look at the WSDL file to see its structure and how it works. Note that this is a very simple WSDL document instance. Our intention is only to illustrate its most significant characteristics. The following content includes more detailed discussions.
<? XML version = "1.0" encoding = "UTF-8"?> <Definitions name = "foosample" Targetnamespace = "http://tempuri.org/wsdl" Xmlns: wsdlns = "http://tempuri.org/wsdl" Xmlns: typens = "http://tempuri.org/xsd" Xmlns: XSD = "http://www.w3.org/2001/XMLSchema" Xmlns: Soap = "http://schemas.xmlsoap.org/wsdl/soap" Xmlns: STK = "http://schemas.microsoft.com/soap-toolkit/wsdl-extension" Xmlns = "http://schemas.xmlsoap.org/wsdl/">
<Types> <Schema targetnamespace = "http://tempuri.org/xsd" Xmlns = "http://www.w3.org/2001/XMLSchema" Xmlns: SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding" Xmlns: WSDL = "http://schemas.xmlsoap.org/wsdl" Elementformdefault = "qualified"> </Schema> </Types>
<Message name = "Simple. foo"> <Part name = "Arg" type = "XSD: int"/> </Message>
<Message name = "Simple. fooresponse"> <Part name = "result" type = "XSD: int"/> </Message>
<Porttype name = "simpleporttype"> <Operation name = "foo" parameterorder = "Arg"> <Input message = "wsdlns: simple. foo"/> <Output Message = "wsdlns: simple. fooresponse"/> </Operation> </Porttype>
<Binding name = "simplebinding" type = "wsdlns: simpleporttype"> <STK: Binding preferredencoding = "UTF-8"/> <Soap: Binding style = "RPC" Transport = "http://schemas.xmlsoap.org/soap/http"/> <Operation name = "foo"> <Soap: Operation soapaction = "http://tempuri.org/action/Simple.foo"/> <Input> <Soap: Body use = "encoded" namespace = "http://tempuri.org/message" Encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </Input> <Output> <Soap: Body use = "encoded" namespace = "http://tempuri.org/message" Encodingstyle = "http://schemas.xmlsoap.org/soap/encoding/"/> </Output> </Operation> </Binding>
<Service name = "foosampleservice"> <Port name = "simpleport" binding = "wsdlns: simplebinding"> <Soap: address location = "http: // CARLOS: 8080/foosample. asp"/> </Port> </Service> </Definitions> |
The following is an overview of this instance document: I will discuss details about each part later.
The first line declares that the document is XML. Although this is not necessary, it helps the XML Parser determine whether to parse the WSDL file or simply report an error. The second line is the root element of the WSDL document: <definitions>. Some attributes are attached to the root element, just like the <schema> child element for the <types> element.
The <types> element contains the types column. If no data type needs to be declared, this column can be default. In the WSDL example, there is no application Program The specific types declaration, but I still use the types column, just to declare schema namespaces.
<Message> the element contains the messages column. If we regard an operation as a function, the <message> element defines the parameter of the function. Each <part> sub-element in the <message> element matches a parameter. The input parameter is defined in the <message> element and is isolated from the output parameter. The output parameter has its own <message> element. Parameters that are used as inputs and outputs have corresponding <part> elements in the <message> element of the input and output. The output <message> element ends with "response", just like the previous "fooresponse ". Each <part> element has a name and a type attribute, just as a function parameter has a parameter name and a parameter type.
When used for document exchange, WSDL allows the use of the <message> element to describe the document to be exchanged.
<Part> the element type can be an XSD base type, a soap definition type (soapenc), a wsdl definition type (WSDL), or a type defined in the types column.
One porttypes column can contain zero, single, or multiple <porttype> elements. Abstract porttype definitions can be placed in separate files. It is possible that no <porttype> element exists in a wsdl file. The preceding example only uses a <porttype> element. One <porttype> element can define one or more operations in the <operation> element. The example uses only one <operation> element named "foo. This is the same as a function name. The <operation> element can have one, two, and three child elements: <input>, <output>, and <fault>. Messages in each <input> and <output> element reference the related <message> element in the message column. In this way, the entire <porttype> element in the example is equivalent to the following C function:
This example shows that XML is much longer than C. (Including elements. XML uses 12 Code In the example to express the same single-row function declaration .)
the bindings column can contain zero, one, or more elements. It is intended to create a network call and response for each . The services column can also have zero, one, and multiple elements. It also contains the element. Each element references the element in the bindings column. The bindings and services columns both contain the WSDL document.