Detailed description of Web Service Description Language WSDL (III)

Source: Internet
Author: User
Tags wsdl example
Namespace

Both <definitions> and <schema> are attributes of namespace:

<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>

 
Each namespace attribute declares an abbreviation used in the document. For example, "xmlns: XSD" is

Http://www.w3.org/2001/xmlschemadefines an abbreviation (XSD ). This allows reference to the namespace simply by name.

You can add a prefix, for example, "XSD" in "XSD: int" is a valid type name. Common range rules can be used to scale the prefix. That is to say, the elements defined by the prefix only have
Effect.

What is the use of namespace? Namespace is used to avoid name conflicts. If I create a web
Service, the WSDL file contains an element named "foo", and you want to use my service to connect with another service as a supplement, so that the WSDL file of another service is
It cannot contain an element named "foo. The two server programs can have the same name only when they represent identical things in two cases. If there is a difference
Namespace, the "foo" in my network service can represent completely different from the meaning of "foo" in another network service. In your client, you only need to restrict it to reference me
".

See the following example: http://www.infotects.com/fooService#foo
Is the name of the limit, equivalent to "CARLOS: foo", if I declare Carlos as a http://www.infotects.com
/Fooservice shortcut. Note that the URLs in namespace are used to determine their uniqueness and facilitate positioning. The URL does not have to actually exist.
Network address. You can also use guid to replace or supplement the URL. For example, guid "335db901-d44a-11d4-a96e-0080ad76435d" is
Valid namespace assignments.

The targetnamespace attribute declares a namespace. All declared names in the element are listed in
. In the WSDL example, the targetnamespace of <definitions>
It is http://tempuri.org/wsdl. This means that all the names declared in the WSDL document belong to this namespace. <Schema> elements have their own
The targetnamespace property whose value is http://tempuri.org/xsd
All the names defined in the <schma> element belong to this namespace rather than the target namespace of main.

<Schema> The following row of the element declares the default namespace. All valid names in the schema belong to this namespace.

Xmlns = "http://www.w3.org/2001/XMLSchema"

SOAP message

For the client and service machine that uses WSDL, one way to study the WSDL file is to decide what to accept the sent information. Do
TCP uses the underlying protocol, such as IP and HTTP, but the application determines the Advanced Protocol for interaction between the server and the client. That is to say, perform an operation, such as "echoint"
The number of parameters, the type of each parameter, and the transfer of parameters determine the specific Protocol of the application. There are many ways to determine such protocols, but I believe the best way is to use
WSDL. If we look at it from this perspective, WSDL is not only an interface protocol, but also a protocol-specific language. It is what we need to go beyond the "fixed" protocol (IP, HTTP, etc.)
Application-specific protocol.

WSDL can determine whether a SOAP message complies with the RPC or document style. RPC-style messages (in the example) Look Like Functions
Call. The message in the document style is more common and the nesting level is smaller. The following XML message is the sending/receiving effect after parsing the WSDL file. The parsing uses Ms soap.
Soapclient object in Toolkit 2.0 (mstk2.

Call the "Foo (5131953)" function from the client:

<? XML version = "1.0" encoding = "UTF-8" standalone = "no"?>
<SOAP-ENV: Envelope
SOAP-ENV: encodingstyle = "http://schemas.xmlsoap.org/soap/encoding"
Xmlns: SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV: Body>
<M: Foo xmlns: M = "http://tempuri.org/message/">
<Arg> 5131953 </Arg>
</M: Foo>
SOAP-ENV: Body>
SOAP-ENV: envelope>
Information received by the slave server:
<? XML version = "1.0" encoding = "UTF-8" standalone = "no"?>
<SOAP-ENV: Envelope
SOAP-ENV: encodingstyle = "http://schemas.xmlsoap.org/soap/encoding"
Xmlns: SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/">
SOAP-ENV: Body>
<Soapsdk1: fooresponse xmlns: soapsdk1 = "http://tempuri.org/message/">
<Result> 5131953 </result>
</Soapsdk1: fooresponse>
SOAP-ENV: Body>
SOAP-ENV: envelope>

 
Both functions call messages, and the response is a valid XML. A soap message consists of the <envelop> element, which contains an optional <Body> elements. The message body called by the RPC function has an element named after the operation "foo", and the response body has a "fooresponse" element. Element Foo has
As described in the WSDL, <Arg> is a single parameter. Fooresponse also has a <result> section. Note:
The predefined definitions in the namespace of encodingstyle, envelope, and message are consistent with those in the WSDL bindings column:

<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>

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.