Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the knowledge of xml in soap

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces what is the knowledge of xml in soap, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

I. Overview of xml

When looking for ways to express soap, the standard setters actually have a variety of options. But in the end, they chose to make use of existing technology as much as possible to minimize the number of necessary new terms. In order to describe the content of the soap message, these authors chose the xml language. Its full name is "extensible Markup Language", extensible markup language.

The xml language contains a lot of features, much more than soap uses or needs to use. For example, in the third section of the soap standard v1.1, "relationships with the xml language", it is stated that "document type descriptions (Document Type Declaration, DTD) shall not be included in soap messages." Processing instructions (Processing Instructions) must not be included in soap messages. In terms of the relevant content of the xml language standard adopted by soap, it defines the use of soap functions. We will soon realize the wisdom of this decision: because developers do not need to have a full-featured xml parser when using soap, it is easy to implement a solution with soap. In order to understand soap, we need to understand the following concepts:

1. Uniform Resource Identifier (Uniform Resource Identifiers, referred to as URI).

Basic of 2.xml language.

3.xml format definition.

4.xml namespace.

5.xml property.

1.1 uniform Resource Identifier

In order to access a unique resource project on the Internet, you must know how to identify it from many objects. The uniform Resource descriptor (URI) is the name given to each resource. The format of URI:

:

The schema-specific-part section also tends to contain slash characters (/) that represent the hierarchy in the path.

1.1.1 uniform Resource Locator (URL)

The most familiar URI is the uniform Resource Locator (Uniform Resource Locator, URL), which is what we usually call the URL address. URL addresses also follow the address representation of URI identifiers.

The format of the schema-specific-part part of the URL address is as follows:

/ /: @: /

The meanings of the constituent elements in the above syntax are as follows:

1.user: the user name at the destination address (optional).

2.password: the password assigned to the user user (optional).

3.host: the Internet protocol address or full domain name of a network host (required).

4.port: the port number used to establish a connection. Most protocols have default port numbers. For example, http uses port 80 to communicate by default (optional).

5.url-path: a detailed path to access a particular resource. The slash character (/) immediately following the hostname or port number is not part of url-path.

1.1.2 uniform Resource name (URN)

Compared with the ubiquitous url address, most web users are much less familiar with the uniform resource name (Uniform Resource Name, URN). The difference between URN and URL is that the former is not resolved into a unique physical location. URN are permanent resource identifiers (unlike URL addresses with some dynamic path information) that allow other types of identifiers from a namespace to be mapped to the URN space. Therefore, the syntax of URN provides the ability to analyze and encode character data using various existing protocols. The composition rules of URN also follow the general rules of URI, and its common formats are as follows:

:: = "urn:":

In the URN name, use the string "urn:" to indicate that this is a URN name. NID is the abbreviation of "Namespace ID", and NSS is the abbreviation of "Namespace-Specific String", which gives the string related to the namespace represented by NID. When we encounter a URN name, we have to decide how to interpret the NSS string based on the value of NID. When reading or using URN names, keep in mind that the leading string "urn:" and the letters in the content are case-sensitive.

URL and URN are the two most common uses of URI. We'll see another use of URI later: xml Namespace (xml namespace).

1.2 xml Foundation

The xml language entered people's eyes from 1996 to 1997. Here is an example of the xml code:

Framework com.**.framework 1.0-SNAPSHOT 4.0.0 war

Even if you've never been through xml code, this example is not difficult to understand. We can see some of the rules for writing xml documents from this code.

(1) the first line is a processing instruction that declares the xml version and encoding format used in this document. This statement in the document is not indispensable, but it is best to load it inside.

(2) the xml document must have a closed element (version information cannot be counted as a closed element). In the example, project includes the entire document between its opening and closing tags. It also has several child elements, which can be nested.

(3) none of the words in this code are xml keywords.

(4) make sure that the marks in the document are not misspelled. The xml parser will accept the document even if it is misspelled, but it will not parse your intention correctly. If we want the xml parser to do some checking for us and only read the correct data structure, you can add a document type description (Document Type Declaration, DTD) or a xml outline (xml schema). DTD is not discussed here, and the third section of the soap technical specification clearly states that "document type declarations shall not be included in soap information."

1.3 xml outline

The xml outline (xml schema) is more descriptive than DTD. Both things provide a way to define the structure of an xml element. Although both the format definition and the DTD allow elements to be defined, only the format definition allows type information for the data to be given. Xml data is text-based and represents the number 4 in binary form such as the character "4" instead of "0100" (xml allows binary data to be encoded in the message, which allows us to send content such as image data in a xml message).

Here is an example to feel the fact that the outline is better than DTD.

A simple DTD has elements that contain other elements or character data. The simplest element declaration is this: give the name of the element, and then define the content of the element as character data. As follows:

An element can be composed of other elements. If an element contains no more or less than one instance of a given element, we define it as follows:

If the parentElement element may contain zero or more childElement elements, we define it with an asterisk (*), as follows:

In addition, you can indicate the combination of elements in a DTD, such as when the parentElement element contains two different pieces of data, as shown below:

For example, if there are many books in the library, and the books have attributes such as title, author, copyright, etc., the defined DTD file Library.dtd can be:

A Library is made up of zero or more elements of type Book. Each Book consists of a Title element, zero or more elements of type Author, and a Copyright element. All three elements Title,Author and Copyright contain character data. We use this DTD to check the xml content, and we can define the xml document:

Green Eggs Dr.Seuss 1957 Windows Scott 2000

The parser automatically loads Library.dtd when it needs to check the type of data and checks the contents of the document against it. The benefits of this are obvious, but wouldn't it be better if we could give more information beyond "this element contains character data"? For a variety of reasons, the W3C finally released a proposed draft of the xml outline. Let's rewrite the DTD document with the xml outline:

Save the above code as a xml file (usually a xsd suffix). When using an outline, simply refer to it in the document, like the following:

Green Eggs Dr.seuss

< myLibrary:Copyright>

1957...

The text "text" is used in both the outline and documentation. The purpose of this string is to inform the parser that the variable names used in this document belong to the namespace specified by the given URI. If the URI starts with x-schema, the parser must load the appropriate outline file from the specified address. Unless otherwise specified, all elements between the opening tag with the xmlns declaration and the corresponding closing tag are part of the specified namespace.

1.3.1 data characteristics

For better data definition and type checking, the xml outline uses "data facets" to define the properties of a particular data type. Each property of a data range space must be defined by a data feature. A "data range space" is a collection of all valid data values for a given data type. Different data types are distinguished by their respective data characteristics. The data features defined by xml outline documents can be divided into two categories: basic features and non-basic features.

A basic feature is an abstract property of data values in a certain data range space, and he gives a basic characteristic of this kind of data values. The basic characteristics of data values include:

1. Equal

two。 Sequence

3. Boundary

4. Potential. This is a concept of set theory. Some values in the range space are limited in number, while others are infinite.

5. Numerical value

6. Length, minimum length, maximum length

7. Style

8. Enumerate

9. Maximum inner boundary, maximum outer boundary, minimum inner boundary, maximum inner boundary

10. Longitude

11. Numerical range

twelve。 Coding mode

13. Duration

14. Cycle

1.3.2 data types

Xml format definition combines data types with data characteristics, which gives an accurate meaning to the data items defined in the format definition. Many data types are defined in www.w3.org/2001/XMLSchema.

1.4 xml Namespace

You've seen the use of xml namespaces (xml namespaces) above. The role of a namespace is simply to define and declare a set of variable names used in a context. Any URN can be used in namespaces, but only if the URN is unique.

1.5 xml attribute

All xml documents that appear in this book use elements to represent data. But you should know that xml also supports the concept of attributes. Elements must have start and end tags, unlike attributes, they don't need tags, just put them in the start tag of the element.

There are three different ways to declare an attribute:

1. A well-written xml, but does not contain any DTD or outline

two。 A carefully written xml, using a DTD

3. A carefully written xml that uses one or more outlines.

The first method works well, but it doesn't work well in a practical environment, and soap forbids the use of DTD, so let's talk about the third method. You need to use the keywords attributeType and attribute when creating properties in the xml outline. These two keywords are meaningful only in the namespace to which the outline belongs. AttributeType is used to define the properties of a type, while attribute indicates the object for which the element type definition is targeted.

In order to use attributes to describe book, the corresponding outline should look like this:

The complete syntax of attributeType is as follows:

Default: the default value of the property.

Xsi:type: the data type of the attribute. If you choose an enumerated type, you also need to xsi:value in the sky.

Name: the name of the attribute type. In order for attributeType to be type checked, there must be a name.

Required: indicates whether an element containing attributeType must have the attributes defined here.

Thank you for reading this article carefully. I hope the article "what is the knowledge of xml in soap" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report