Web Service Description Language WSDL Walkthrough (2)--wsdl file example [turn]

Source: Internet
Author: User
Tags definition soap xml parser xmlns wsdl
web| Example | Let's look at the WSDL file, see its structure, and how it works. Please note that this is a very simple instance of a WSDL document. Our intention is only to illustrate its most salient features. The following sections include a more detailed discussion.

<?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/FooSample.asp"/>
</port>
</service>
</definitions>
The following is a general summary of the example document: I'll discuss each of the details later in detail.

The first line declares that the document is XML. Although this is not required, it helps the XML parser decide whether to parse the WSDL file or simply make an error. The second line is the root element of the WSDL document: <definitions>. Some properties are attached to the root element, just as <schema> child elements are to <types> elements.

The <types> element contains the types column. If you do not have the data type you want to declare, this column can be default. In the WSDL paradigm, there is no application-specific types declaration, but I still use the types column just to declare the schema namespaces.

The <message> element contains the messages column. If we think of an action as a function, the <message> element defines the parameters of that function. Each <part> child element in the <message> element matches a parameter. The input parameter is defined in the <message> element, separated from the output parameter-the output parameter has its own <message> element. Parameters that are both input and output have their corresponding <part> elements in the <message> elements of the input and output. The output <message> element ends with "Response", just as the "fooresponse" used previously. Each <part> element has a name and a type attribute, just as a function's argument has a parameter name and a parameter type.

When used to exchange documents, the WSDL allows you to use the <message> element to describe the exchanged document.

The <part> element's type can be either an XSD base type or a SOAP definition type (SOAPENC), a WSDL definition type (WSDL), or a type defined by the types column.

In a porttypes column, you can have 0, single, or multiple <portType> elements. Because abstract portType definitions can be placed in separate files, it is possible to have no <portType> elements in a WSDL file. In the example above, only one <portType> element is used. An <portType> element can define one or more actions in the <operation> element. The example uses only a <operation> element named "foo". This is the same as a function name. The <operation> element can have one, two, three child elements: <input>, <output>, and <fault> elements. The messages in each <input> and <output> element refer to the associated <message> element in the message bar. Thus, the entire <portType> element in the example is equivalent to the following C function:

int foo (int arg);
This example shows that XML is much more verbose than C. (including the <message> element, XML uses 12 lines of code in the example to express the same Single-line function declaration.) )

The bindings column can have 0, one, or more <binding> elements. Its intention is to make each <operation> call and respond through the network. The services bar can also have 0, one, and multiple <service> elements. It also contains <port> elements, each of which references a <binding> element in a bindings column. Both the bindings and the Services bar contain WSDL documents.

Original address: http://www.yesky.com/20011013/200759_1.shtml

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.