WSDL file in detail (paste)

Source: Internet
Author: User
Tags date integer soap range xmlns wsdl
Detailed description of the XML structure in the WSDL type and Information section
The data type of the WSDL is the "xml schema:datatypes" (XSD), according to the current recommendation of the consortium. There are three different versions of this file (1999, 2000/10, and 2001), and if you want to specify which version to use for a particular WSDL document, declare it as a namespace in the <definitions> element. The method is as follows:

Xmlns:xsd= "Http://www.w3.org/2001/XMLSchema"

This article is only based on the 2001 version of the consideration. The WSDL Standard Protector also strongly advocates the use of version 2001.

In this episode and subsequent chapters, the following is the first or named space speed notation:

The name space of the first word
SOAPENC http://schemas.xmlsoap.org/soap/encoding SOAP 1.1 encoded
WSDL Http://schemas.xmlsoap.org/wsdl/soap WSDL 1.1
XSD Http://www.w3.org/2001/XMLSchema XML Schema

XSD Basic Types
The following table is taken directly from the MSTK2 file, which lists all the XSD basic types supported by MSTK2. The table explains how the WSDL reader at the client and server level applies the XSD type to different and equal types in VB, C + +, and IDL.

Different types of XSD (SOAP) type VB C + + IDL annotations
AnyURI vt_bstr String BSTR BSTR
Base64binary Vt_array | Vt_ui1 Byte () SAFEARRAY SAFEARRAY (unsigned char)
Boolean Vt_bool boolean Variant_bool variant_bool
BYTE VT_I2 Integer short-short transformation time test range.
Date Vt_date Date date is Oo:oo:oo
DateTime vt_date Date Date
Double VT_R8 double Double
Duration VT_BSTR String BSTR BSTR No validation or conversion
Entities VT_BSTR String BSTR BSTR No validation or conversion
ENTITY vt_bstr String BSTR BSTR No validation or conversion
Float VT_R4 single float float
Gday vt_bstr String BSTR BSTR No validation or conversion
Gmonth vt_bstr String BSTR BSTR No validation or conversion
gMonthDay vt_bstr String BSTR BSTR No validation or conversion
Gyear vt_bstr String BSTR BSTR No validation or conversion
Gyearmonth vt_bstr String BSTR BSTR No validation or conversion
ID vt_bstr String BSTR BSTR No validation or conversion
IDREF vt_bstr String BSTR BSTR No validation or conversion
IDREFS vt_bstr String BSTR BSTR No validation or conversion
int VT_I4 Long Long
The integer vt_decimal Variant decimal decimal Transformation Experience range.
Language VT_BSTR String BSTR BSTR No validation or conversion
Long vt_decimal Variant Decimal decimal Transformation Experience range.
Name vt_bstr String BSTR BSTR No validation or conversion
NCName vt_bstr String BSTR BSTR No validation or conversion
The Negativeinteger vt_decimal Variant Decimal Decimal Transformation time range.
NmToken vt_bstr String BSTR BSTR No validation or conversion
Nmtokens vt_bstr String BSTR BSTR No validation or conversion
The nonNegativeInteger vt_decimal Variant Decimal Decimal Transformation time range.
The nonPositiveInteger vt_decimal Variant Decimal Decimal Transformation time range.
normalizedstring vt_bstr String BSTR BSTR
notation Vt_bstr String BSTR BSTR No validation or conversion
Number Vt_decimal Variant Decimal decimal
The positiveinteger vt_decimal Variant Decimal Decimal Transformation time range.
QName vt_bstr String BSTR BSTR No validation or conversion
Short VT_I2 Integer Short
String Vt_bstr string BSTR BSTR
Time Vt_date Date date is set to December 30, 1899
Token vt_bstr String BSTR BSTR No validation or conversion
Unsignedbyte vt_ui1 Byte unsigned char unsigned char
The Unsignedint vt_decimal Variant Decimal Decimal Transformation time range.
The Unsignedlong vt_decimal Variant Decimal Decimal Transformation time range.
Unsignedshort Vt_ui4 A long long long switch.

XSD defines the data types in both groups: basic types and derived types. For further information, you can go to the http://www.w3.org/TR/2001/PR-xmlschema-2-20010330 and view the hierarchical structure of the built type.

Complex types
XML schemas can be defined as complex types, i.e., struct in C. For example, the following C struct are defined in terms of:

typedef struct {
String FirstName;
String LastName;
Long Ageinyears;
float weightinlbs;
float heightininches;
} person;

If you use an XML Schema, you can write:

<xsd:complextype name= "Person" >
<xsd:sequence>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:sequence>
</xsd:complexType>

But what,<complextype> can say is not just the struct. In addition to <sequence>, it can have other child elements. If &LT;SEQUENCE&GT is not necessary, the &LT;ALL&GT can be used:

<xsd:complextype name= "Person" >
<xsd:all>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:all>
</xsd:complexType>

The implication is that the member variables <element> can be entered in any order, and each of these options is optional. This is different from the way C struct is used.

Notice how the data types such as String (string), int (integer), float (float), and so on are used in the example. C's string is also a string in XML, and the floating-point number is a floating point number. But the long (length) of C, in XML, is int (please enter the table).

In the WSDL file, the Types section is where the complex type is declared. For example, the person type can be declared in the following manner and used in the Messages section:

<?xml version= "1.0" encoding= "UTF-8"?>
<definitions?>
<types>
<schema targetnamespace= "SomeNamespace"
xmlns:typens= "SomeNamespace" >
<xsd:complextype name= "Person" >
<xsd:sequence>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</schema>
</types>

<message name= "Addperson" >
<part name= "Person" type= "Typens:person"/>
</message>

<message name= "Addpersonresponse" >
<part name= "Result" type= "Xsd:int"/>
</message>

</definitions>

In the example above, the first message is named "addperson", which has a <part> of a type "person". In the Types section, the type person is declared to be complex type.

When you start MSTK2 soapclient, you can successfully parse the file by using the full WSDL file in the fragment above. However, it is still not possible to send the function to <addPerson>. This is because soapclient itself does not know how to handle complex types; it needs a custom type of sensor (mapper) to handle complex types. There is a sample application in the MSTK2 file that contains a custom type of sensor.

There is also a method that can be used to connect <part> elements to type declarations. This method uses elements rather than types. The next example would be to declare two elements ("person" and "gender") in the Types area, and then in the <message> of "addperson", use the element attributes to refer to them.

<?xml version= "1.0" encoding= "UTF-8"?>
<definitions?>
<types>
<schema targetnamespace= "SomeNamespace"
xmlns:typens= "SomeNamespace" >
<element name= "Person" >
<xsd:complexType>
<xsd:sequence>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:sequence>
</xsd:complexType>
</element>
<element name= "Gender" >
<xsd:simpleType>
<xsd:restriction base= "Xsd:string" >
<xsd:enumeration value= "Male"/>
<xsd:enumeration value= "Female"/>
</xsd:restriction>
</xsd:simpleType>
</element>
</schema>
</types>

<message name= "Addperson" >
<part name= "who" element= "Typens:person"/>
<part name= "Sex" element= "Typens:gender"/>
</message>

<message name= "Addpersonresponse" >
<part name= "Result" type= "Xsd:int"/>
</message>
</definitions>

In the Gender <element> of the Types section, an anonymous column type is embedded, and the value can be "male" or "female". Then, in the <message> of "addperson", the element is used (without type) to participate in it.

What is the difference between the use of "element" and "type" if you want to relate specific types to &LT;PART&GT? If "type" is used, part can be described as being able to take a number of types (as in the case of a variable), but it cannot be done by using "elemental" attributes. Please refer to the following examples.

<?xml version= "1.0" encoding= "UTF-8"?>
<definitions?>
<types>
<schema targetnamespace= "SomeNamespace"
xmlns:typens= "SomeNamespace" >
<xsd:complextype name= "Person" >
<xsd:sequence>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complextype name= "Femaleperson" >
<xsd:complexContent>
<xsd:extension base= "Typens:person" >
<xsd:element name= "Favoritelipstick" type= "xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complextype name= "Maleperson" >
<xsd:complexContent>
<xsd:extension base= "Typens:person" >
<xsd:element name= "favoriteshavinglotion" type= "xsd:string"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complextype name= "Maleorfemaleperson" >
<xsd:choice>
<xsd:element name= "Farg" type= "Typens:femaleperson" >
<xsd:element name= "MArg" type= "Typens:maleperson"/>
</xsd:choice>
</xsd:complexType>
</schema>
</types>

<message name= "Addperson" >
<part name= "Person" type= "Typens:maleorfemaleperson"/>
</message>

<message name= "Addpersonresponse" >
<part name= "Result" type= "Xsd:int"/>
</message>

</definitions>

This example also illustrates the derivative use of the file name. Both "femaleperson" and "maleperson" are derived from "person". They all have an extra element: "femaleperson" 's "favoritelipstick" and "maleperson" 's "favoriteshavinglotion". Using the <choice> construct, these two derived types can also be combined to synthesize a complex type of "maleorfemaleperson". Finally, in the <message> of "addperson", this type of "person" is also available for <part> participation. And this <part> or the parameters can be "femaleperson" or "maleperson".

Array
XSD can provide <list> construct to declare a blank delimited array of entries. However, SOAP does not use XSD "soap-enc:array" to encode the array, but to define its own type, that is, the matrix. The following example shows how the whole array of single dimensions leads to this type in its own way:

<xsd:complextype name= "Arrayofint" >
<xsd:complexContent>
<xsd:restriction base= "Soapenc:array" >
<attribute ref= "Soapenc:arraytype" wsdl:arraytype= "xsd:int["/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

You can declare a new complex type from Soapenc:array as long as you use a limited way. Then we can declare this complex type of arraytype: The "soapenc:arraytype" is actually a declaration of arraytype, in the following way:

<xsd:attribute name= "ArrayType" type= "xsd:string"/>

Then, the wsdl:arraytype can determine the type of each array. Arrays can also be complex types:

<xsd:complextype name= "Arrayofperson" >
<xsd:complexContent>
<xsd:restriction base= "Soapenc:array" >
<attribute ref= "Soapenc:arraytype"
Wsdl:arraytype= "typens:person[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>

The WSDL requirement is that the type name of the array must be the "arrayof" (concatenation) of the array item type. As a result, "arrayofperson" is an array of person struct. In the following example, if you use Arrayofperson to declare a <message&gt, you can add more person:

<?xml version= "1.0" encoding= "UTF-8"?>
<definitions?>
<types>
<schema targetnamespace= "SomeNamespace"
xmlns:typens= "SomeNamespace" >
<xsd:complextype name= "Person" >
<xsd:sequence>
<xsd:element name= "FirstName" type= "xsd:string"/>
<xsd:element name= "LastName" type= "xsd:string"/>
<xsd:element name= "Ageinyears" type= "Xsd:int"/>
<xsd:element name= "weightinlbs" type= "Xsd:float"/>
<xsd:element name= "heightininches" type= "Xsd:float"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complextype name= "Arrayofperson" >
<xsd:complexContent>
<xsd:restriction base= "Soapenc:array" >
<attribute ref= "Soapenc:arraytype"
Wsdl:arraytype= "typens:person[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</schema>
</types>

<message name= "Addpersons" >
<part name= "Person" type= "Typens:arrayofperson"/>
</message>

<message name= "Addpersonresponse" >
<part name= "Result" type= "Xsd:int"/>
</message>

</definitions>

<portType> <operation> Elements
PortType can define many kinds of professions in the abstract. The PortType element in the code, which defines the language that calls all PortType methods. Each operating element declares the name of the method, the parameters (using the <message> element), the type (the <part> element declared in each <message>).

In a WSDL file, you can have more than one <portType> element. Each <portType> element, a group of ways of doing business, is very similar to the way the COM interface group is structured.

In a <operation> element, you can have a maximum of one <input> element, one <output> element, and one <fault> element. Each of these three elements has a name and information.

What is the purpose of using name in <input>, <output>, and <fault> elements? The original is for the two industries with the same name (multiple downloads). For example, the following two C functions, which have the same name, but different parameters.

void foo (int arg);
void foo (string arg);

When using WSDL, this is a much-downloaded expression:

<?xml version= "1.0" encoding= "UTF-8"?>
<definitions name= "Foodescription"
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= "Foo1" >
<part name= "arg" type= "Xsd:int"/>
</message>

<message name= "Foo2" >
<part name= "arg" type= "xsd:string"/>
</message>

<porttype name= "Foosampleporttype" >
<operation name= "foo" parameterorder= "arg" >
<input name= "foo1" message= "Wsdlns:foo1"/>
</operation>
<operation name= "foo" parameterorder= "arg" >
<input name= "Foo2" message= "Wsdlns:foo2"/>
</operation>
</portType>

<binding name= "foosamplebinding" type= "Wsdlns:foosampleporttype" >
<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/foo1"/>
<input name= "Foo1" >
<soap:body use= "encoded" namespace= "http://tempuri.org/message/"
encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
<operation name= "foo" >
<soap:operation soapaction= "Http://tempuri.org/action/foo2"/>
<input name= "Foo2" >
<soap:body use= "encoded"
Namespace= "http://tempuri.org/message/"
Encodingstyle= "http://schemas.xmlsoap.org/soap/encoding/"
/>
</input>
</operation>
</binding>

<service name= "Fooservice" >
<port name= "Foosampleport" binding= "foosamplebinding" >
<soap:address
location= "Http://carlos:8080/fooService/foo.asp"/>
</port>
</service>
</definitions>


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.