Integration of SOAP Technology and B2B Application (4)
Sample / value in the SOAP message and examples
This article was originally published by the IBM DeveloperWorks China website, its URL is http://www.ibm.com/developerworks/cn/
In the previous article SOAP system and data coding rules, we can understand that SOAP's type and data encoding is based on a simple type system, this simple type system is based on programming language, database, and semi-structured data. The system is a generalization of the public characteristics of the type system in the program language, database, and semi-structural data. In this simple type system, a type is either a simple (quantified) type or a composite type, which consists of multiple parts, each of which is a type (including simple type or composite type). Then, this paper details the type and value of the type and value in detail, respectively, respectively, respectively, and it is desirable to give readers to clearly understand and master by detailed examples.
XML Schema provides a high flexibility and a definition description of the type of a type with good scalability. The SOAP specification mainly uses XML Schema as the definition language of its type mode. Of course, since SOAP is open, flexible, you can use other mode-defined XML Application to develop types and values of specific applications. Description.
Simple type
For simple types, SOAP has all types defined in "XML Schema Part 2: DataTypes", including values and vocabulary spaces. Examples include:
TYPE EXAMPLE INT 58502 FLOAT 314159265358979E 1 NegativeInteger -32768 String Louis "Satchmo" Armstrong
The data type declared in the XML Schema specification can be used directly in element mode. The type of these types can also be used. Below is an example of a pattern fragment and a corresponding type of element data:
Whether the simple value type is defined in the "XML Schema Part 2: DataTypes" specification, or based on the type definition mechanism provided by the XML Schema specification must be encoded as an element.
If a simple value is encoded as an independent element or a heterogeneity element, this means there is an element declaration corresponding to the data type. Because the "XML Schema Part 2: DataTypes" specification contains type definition, it is not included in the declaration of the corresponding element, and the SOAP-ENC mode and the namespace declare an element for each simple data type. These definitions can be used.
String
"String" Data Type is defined in "XML Schema Part 2: DataTypes". It is worth noting that in many databases or programming languages, the "string" type is not consistent. In some special languages, only some characters may appear in "String". (These values may need to represent some data types other than XSD: String)
A string can be encoded as a single reference or multi-reference value.
Elements containing the string value can have a "id" attribute. Additional access identification elements can have the "href" property that matches it.
For example, if there are two access identities to the same String, it can be manifested as:
In any case, there is no essential difference between a String (or String Subtyprise Subtyprise), two references to two references to two single reference values:
The mode description for these examples may be:
(In this example, the SOAP-ENC: String type for describing the element type is a way to use, using such a definition to describe the type of element is "XSD: String", and it can come with "ID" and "HREF" attribute. You can see SOAP ENCODING Schema to get the exact definition. Instance mode can also use declarations in these SOAP Encoding mode, but this is not necessary.)
enumerate
The "XML Schema Part 2: DataTypes" specification defines a mechanism called "Rapid Enumeration". The SOAP data model uses this mechanism. However, due to some subtle differences in the definition, there are some subtle differences in the definition, we describe more detailed concepts and describe how to encode one of the values that become a list of Raised lists. Specifically, it encodes the name of this value.
In concept, "Rapu" expressed a group of different names. A concrete rose is a specific list of different values that meet the basic type. For example, a collection of color names ("Green", "BLUE", "brown") can be defined as a rose, value ("1", "3", "5") based on built-in String type, may be one Based on Integer's Rapu, and so on. "XML Schema Part 2: DataTypes" specification supports all simple types of simple types outside Boolean. The "XML Schema Part 2: Structure" specification language can be used to define the type of rose. If a mode is generated from another symbol system without a specific basic type, then "String" is used. In the following mode example, "EyColor" is defined as a String's rising, which may include "Green", "Blue", "brown", while instance data is also given.
BYTE array
A Byte array can be encoded as a single reference or multi-reference value. The coding rule of the Byte array is similar to string.
Special, elements containing a Byte array value can have a "id" attribute. Additional access identification elements can have a "href" attribute for matching.
Recommended representation of an opaque BYTE array is to use the "Base64" encoding method defined in the XML Schema specification, and the specific encoding algorithm is defined in RFC 2045. However, the data line length of Base64 encoded data in MIME will not exist in SOAP. The "SOAP-ENC: Base64" subtype should be used in SOAP to define Base64 encoding.
Polymorphism
Many languages allow access identities to be a polymorphically accessible number of values, each type can be used at runtime. A polymorphic access identification instance must contain a "XSI: Type" property to describe the actual value of the type.
For example, a polymorphic access identifier named "COST" with a value of "XSD: float" can be encoded as:
The relative to it is a value type unchanged COST access ID.
The specific representation of the polymorphism will only appear in the example, but the definition of the polymorphism is in the mode, that is, in the mode, any specified type should not be bound.
Compound type
SOAP defines composite types in accordance with the following structural patterns that often see in the program language:
structure
"STRUCT Structure" is a composite type value, and its member's access identification name is the unique flag of mutual distinction, and should be different from each other.
Array
"Array Array" is a composite type value, and its membership position is the unique sign of mutual distinguishes.
References of composite values, structures and values
Members of the composite value are encoded to access identification elements. The access identifier is distinguished by their name (eg, in Struct), and the element name is to access the identification name. The access identity name is part, the scope is included in their type, with an unmodified element name, while others have a complete modifier.
Here is an example of a "book" structure:
The following is a mode segment describing the structure:
Below is an example of a type containing a simple type member also contains a composite type member. It shows two layers of references. Note that the "HREF" attribute of "Author" access identification element is referenced to the value corresponding to the "ID" value. The situation in "Address" is also similar.
The above description is appropriate when "Person" and "Address" is needed. If you use single to describe, it should be embedded, as follows:
If there is a limit here: two people are not allowed in a given instance, and the address can be a street-address, or an electronic address (Electronic-Address). A book with two authors can be encoded as:
The order can also contain some references that are not in the same resource:
Simultaneously below is a mode description fragment of the above structure:
The SOAP array is defined as the type "soap-enc: array" or type originated from "soap-enc: array" [see Rule 8]. An array is expressed as an element value that is not particularly constrained for an element containing its elements (the value of elements generally does not constrain the name).
An array can contain any type of element, including a nested array. New types established by SOAP-ENC: Array can also be created and indicated, for example, arrays can be limited to arrays of integers or some user custom rose types.
The representation of the array value is an ordered sequence that consists of an elemental sequence of elements. As a value of an array, the element name is not important for distinguishing access identification. Elements can have any name. In fact, the naming of these elements will be determined by the recommendations declared in the mode or by their type. As usual in the composite type, if the value of the entries in the array is single-quoted value, the entry will contain its value. Otherwise, the entry references its value through the "href" attribute.
Below is a plurality of segments and an array containing Integer members:
As previously pointed, the SOAP-ENC mode contains some of the declarations of the element name, and these names correspond to each of the "XML Schema Part 2: DataTypes" specification. This also includes a statement of "array". Using these definitions, we may be able to reverse the previous description to rewrite as: Member Element Type You can use XSI: TYPE in an example, or declare in member element mode, as shown in the following two arrays. The above example shows how an array is encoded as an independent element, and the array value can appear in a nested manner, if and they are single, it is recommended to appear in nested. Below is an example of a pattern fragment and a telephone number array in accordance with the mode in the "Person" structure, which can be accessed from the access identifier "Phone-NumBers". SOAP provides support for partial delivery arrays, which is like "variable long" arrays called in some cases. A partial transfer number should use the "SOAP-ENC: Offset" attribute identifier, which is started with the displacement of the first element. If this property is omitted, the displacement is 0. Below is an array of size 5, while only passing the third and fourth elements at the time of delivery: SOAP root properties can appear in any child elements in the SOAP header and SOAP body elements, which does not have a default. This attribute is generally used to use a non-nested method (by multi-reference to implement), due to the plurality of forms of the same level, there is a need to identify the true root.