教程
SOAP
SOAP
SOAP
SOAP是一个简单的基于XML的协议,它让应用程序跨HTTP进行信息交换。
SOAP
在我们的SOAP
SOAP
换的
教程,你将了解什么是SOAP,以及它是怎样利用XML来让程序间的信息进行交
内容目录
SOAP 介绍
This chapter explains what SOAP is and why SOAP is useful.
介绍了什么是SOAP以及它的用处
SOAP 语法
This chapter describes the building blocks of SOAP and SOAP syntax rules.
这章介绍了如何建立SOAP块结构和SOAP的语法规则
SOAP Envelope
This chapter describes the SOAP Envelope element.
SOAP的封套元素
SOAP Header
This chapter describes the SOAP Header element.
这章介绍了SOAP的Header[报头]元素
SOAP Body
This chapter describes the SOAP Body element.
这章介绍了SOAP的Body元素
SOAP Fault
This chapter describes the SOAP Fault element.
这章介绍了SOAP的默认元素
SOAP HTTP Binding
This chapter is an introduction to the SOAP HTTP binding.
介绍有关SOAP HTTP 绑定
SOAP 举例
This chapter describes a SOAP example.
一个SOAP的举例
SOAP 摘要
SOAP
SOAP
SOAP
介绍
///
w3pop.com
2006-09-19
w3pop.com
w3pop.com
2006-09-19
2006-09-19
SOAP is a simple XML based protocol to let applications exchange information over HTTP.
SOAP是一个简单的基于XML的协议,它让应用程序跨HTTP进行信息交换。
Or more simply: SOAP is a protocol for accessing a Web Service.
或者更简单的:SOAP是用于访问网络服务的协议。
WhatWhatWhat
YouYouYou
Should
Should
Should
Already
Already
Already
KnowKnowKnow
你应该已经了解的:
Before you study SOAP you should have a basic understanding of XML and XML Namespaces.
在你学习SOAP 之前,你应该能基本理解以下XML和XML命名空间。
If you want to study these subjects first, please read our XML Tutorial.
如果你想继续看下去,请先访问XML 教程.
WhatWhatWhat
isisis
SOAP?
SOAP?
SOAP?
SOAP?
什么是SOAP?
SOAP?
Simple
SOAP stands for Simple
Simple
Object
Object
Object
Access
Access
Access
Protocol
Protocol
Protocol
SOAP代表Simple Object Access Protocol(简单对象访问协议)
communication
SOAP is a communication
communication
SOAP是通讯协议
between
SOAP is for communication between
between
protocol
protocol
protocol
applications
applications
applications
SOAP用于应用程序之间的通讯
sending
SOAP is a format for sending
sending
SOAP是一种信息发送的格式
messages
messages
messages
SOAP is designed to communicate viaviavia
Internet
Internet
Internet
SOAP是通过因特网来通讯的
platform
SOAP is platform
platform
SOAP是独立的平台
language
SOAP is language
language
SOAP是独立的语言
ononon
based
SOAP is based
based
independent
independent
independent
independent
independent
independent
XMLXMLXML
SOAP是建立在XML基础之上的
extensible
extensible
extensible
simple
SOAP is simple
simple
andandand
SOAP是简单并可以扩展的
SOAP allows you to getgetget
around
around
around
firewalls
firewalls
firewalls
SOAP允许透过防火墙传播
SOAP will be developed as a W3CW3CW3C
standard
standard
standard
SOAP会以W3C标准为标准而发展起来。
WhyWhyWhy
SOAP?
SOAP?
SOAP?
SOAP
为什么使用SOAP
SOAP
?
It is important for application development to allow Internet communication between programs.
对应用程序而言,允许程序之间的因特网通讯是非常重要的。
Today's applications communicate using Remote Procedure Calls (RPC) between objects like DCOM
and CORBA, but HTTP was not designed for this. RPC represents a compatibility and security
problem; firewalls and proxy servers will normally block this kind of traffic.
如今的应用软件都是通过对象之间的RPC(远程过程调用,如:DCOM和CORBA)来实现通讯
的,但是HTTP却不是这样的。RPC表现为兼容性和安全问题。一般情况下,防火墙和代理服务
器会阻塞流量。
A better way to communicate between applications is over HTTP, because HTTP is supported by all
Internet browsers and servers. SOAP was created to accomplish this.
因为所有的因特网浏览器都支持HTTP,所以在应用程序之间进行通讯还有一个更好的办法,就
是跨HTTP。SOAP就是基于这个理论而被创建出来的。
SOAP provides a way to communicate between applications running on different operating systems,
with different technologies and programming languages.
SOAP提供了一条途径使在不同操作系统上运行的应用程序间实现通讯(通过不同技术和程序设
计 语 言 )。
Microsoft
Microsoft
Microsoft
andandand
SOAP
SOAP
SOAP
SOAP
微软和SOAP
SOAP
SOAP is a key element of Microsoft's .NET architecture for future Internet application development.
在未来因特网应用程序发展进程中,SOAP是微软.NET体系结构的主要元素。
SOAP
SOAP
SOAP
1.11.11.1
waswaswas
Proposed
Proposed
Proposed
tototo
W3CW3CW3C
向W3CW3CW3C
SOAP1.1
提议SOAP1.1
SOAP1.1
UserLand, Ariba, Commerce One, Compaq, Developmentor, HP, IBM, IONA, Lotus, Microsoft, and
SAP proposed to W3C, in May 2000, the SOAP Internet protocol that they hope will revolutionize
application development by connecting graphic user interface desktop applications to powerful
Internet servers using the standards of the Internet: HTTP and XML.
在2000年5月,UserLand, Ariba, Commerce One, Compaq, Developmentor, HP, IBM, IONA, Lotus,
Microsoft和 SAP对W3C做出提议:他们所设想的SOAP英特网协议将通过使用HTTP以及XML
两个网络标准把图形用户界面桌面应用程序(graphic user interface desktop applications)连接到
强大的英特网服务中。
W3CW3CW3C
isisis
Working
Working
Working
ononon
SOAP
SOAP
SOAP
1.21.21.2
W3CW3CW3C
SOAP
将在SOAP
SOAP
1.21.21.2
上运行
The first public Working Draft on SOAP was published from W3C in December 2001. To read more
about the SOAP activities at W3C please visit our W3C tutorial.
2001年12月,SOAP上的第一份公共工作草案将在W3C上公布。如想了解更多SOAP在W3C上的
活动,请访问W3C 教程。
语法
SOAP
SOAP
SOAP
///
w3pop.com
2006-09-21
w3pop.com
w3pop.com
2006-09-21
2006-09-21
SOAP
SOAP
SOAP
Building
Building
Building
Blocks
Blocks
Blocks
SOAP
SOAP
SOAP
组件群
A SOAP message is an ordinary XML document containing the following elements:
Soap信息是包含以下元素的普通XML文件。
A required Envelope element that identifies the XML document as a SOAP message
必需的把XML文件定义为SOAP信息的封套(Envelope)元素
An optional Header element that contains header information
包含标题信息的可选标题(header)元素
A required Body element that contains call and response information
包含请求与响应信息的必要主体元素
An optional Fault element that provides information about errors that occurred while processing the
message
处理信息时,提供关于产生错误信息的可选择的错误元素
All the elements above are declared in the default namespace for the SOAP envelope:
上面所有元素都在SOAP 封套(envelope)的错误命名空间中被声明
http://www.w3.org/2001/12/soap-envelope
and the default namespace for SOAP encoding and data types is:
SOAP编码和数据类型的的错误命名空间是:
http://www.w3.org/2001/12/soap-encoding
Syntax
Syntax
Syntax
RulesRulesRules
语法规则
Here are some important syntax rules:
下面是一些重要的语法规则:
A SOAP message MUST be encoded using XML
SOAP信息必须通过XML进行编码
A SOAP message MUST use the SOAP Envelope namespace
SOAP信息必须使用SOAP 封套(Envelope)命名空间(namespace)
A SOAP message MUST use the SOAP Encoding namespace
SOAP 信息必须使用SOAP编码命名空间
A SOAP message must NOT contain a DTD reference
SOAP信息决不能包含DTD参数
A SOAP message must NOT contain XML Processing Instructions
SOAP信息决不能包含XML处理指令
Skeleton
Skeleton
Skeleton
SOAP
SOAP
SOAP
Message
Message
Message
)信息
Skeleton
纲要(Skeleton
Skeleton
SOAP
SOAP
SOAP
...
...
...
...
...
...
SOAP
SOAP
SOAP
封套
///
w3pop.com
2006-09-21
w3pop.com
w3pop.com
2006-09-21
2006-09-21
The mandatory SOAP Envelope element is the root element of a SOAP message.
具有强制性的SOAP封套(Envelope)元素是SOAP信息的根元素。
TheTheThe
SOAP
SOAP
SOAP
Envelope
Envelope
Envelope
Element
Element
Element
SOAP
SOAP
SOAP
封套元素
The required SOAP Envelope element is the root element of a SOAP message. It defines the
XML document as a SOAP message.
必要的SOAP封套元素是SOAP元素的根元素。它把XML文件定义为SOAP信息。
Note the use of the xmlns:soap namespace. It should always have the value of:
注意xmlns:soap命名空间(namespace)的使用。它一般含有以下值:
http://www.w3.org/2001/12/soap-envelope
and it defines the Envelope as a SOAP Envelope:
它以SOAP 封套(Envelope)的形式定义了封套(Envelope)。
...
Message information goes here
...
xmlns:soap
xmlns:soap
xmlns:soap
TheTheThe
xmlns:soap
xmlns:soap
xmlns:soap
Namespace
Namespace
Namespace
命名空间
A SOAP message must always have an Envelope element associated with the
"http://www.w3.org/2001/12/soap-envelope" namespace.
SOAP信息必须含有与"http://www.w3.org/2001/12/soap-envelope" 命名空间相关的Envelope
元素。
If a different namespace is used, the application must generate an error and discard the
message.
如果使用了不同的命名空间,那应用程序肯定会产生一个错误信息并忽略信息。
TheTheThe
encodingStyle
encodingStyle
encodingStyle
Attribute
Attribute
Attribute
encodingStyle
encodingStyle
encodingStyle
属性
The SOAP encodingStyle attribute is used to define the data types used in the document.
This attribute may appear on any SOAP element, and it will apply to that element's contents
and all child elements. A SOAP message has no default encoding.
SOAPencodingStyle属性的作用:定义用于文档中的数据类型。属性可能会在任何SOAP元素
中出现,并且会应用于元素的内容及其所有子元素上。SOAP信息没有默认编码。
Syntax
Syntax
Syntax
语法
soap:encodingStyle="URI"
Example
Example
Example
实例
...
Message information goes here
...
SOAP
Header
SOAP
SOAP
Header
Header
///
w3pop.com
2006-09-21
w3pop.com
w3pop.com
2006-09-21
2006-09-21
The optional SOAP Header element contains header information.