SOAP 学习笔记
来源:互联网 发布:陈柏良知乎 编辑:程序博客网 时间:2024/05/23 20:13
SOAP:
Simple:
用XML来呈现数据,并且通过HTTP来传输它是Simple的!
SOAP请求的每个方面都试图成为一个自我描述并且基于大量验证集和构建良好的协议。
基于消息的文档交换和RPC:
SOAP在通过HTTP进行同步远程过程调用中有它自己的roots,
同步RPC,异步的基于消息的文档交换模型。
文档交换模型是两个endpoint之间数据交换的一种默认方法。
一个RPC Call实际上就是一个例子: 将多个单程异步报文合并成一个请求-响应
SOAP Message:
1)formatting conventions for encapsulating data:
The envelope defines a convention for describing the contents of a message, which in turn has implications on how it gets processed
2)Encoding rules: provide a convention for mapping various application datatypes into an XML tag-based representation
3)a transport or protocol binding:provides a generic mechanism for sending a SOAP envelope via a lower-level protocol such as HTTP
4)RPC mechanism: provides a way to represent remote procedure calls and their return values
到底什么样的XML能成为SOAP ?
<?xml version="1.0" encoding="UTF-8"?>
<PurchaseOrder xmlns="urn:oreilly-jaws-samples">
<shipTo country="US">
<name>Joe Smith</name>
<street>14 Oak Park</street>
<city>Bedford</city>
<state>MA</state>
<zip>01730</zip>
</shipTo>
<items>
<item partNum="872-AA">
<productName>Candy Canes</productName>
<quantity>444</quantity>
<price>1.68</price>
<comment>I want candy!</comment>
</item>
</items>
</PurchaseOrder>
还要哪些东西才能使上面这个普普通通的XML文档成为一个响当当的SOAP?
1 The wrapping of the XML inside of a SOAP body
2 The wrapping of the SOAP body within a SOAP envelope
3 The optional inclusion of a SOAP header block
4 Namespace declarations
5 Encoding style directives for the serialization of data
6 The binding of the whole thing to a protocol
请看下面这个:
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
...
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<PurchaseOrder xmlns="urn:oreilly-jaws-samples">
<shipTo country="US">
<name>Joe Smith</name>
<street>14 Oak Park</street>
<city>Bedford</city>
<state>MA</state>
<zip>01730</zip>
</shipTo>
<items>
<item partNum="872-AA">
<productName>Candy Canes</productName>
<quantity>444</quantity>
<price>1.68</price>
<comment>I want candy!</comment>
</item>
</items>
</PurchaseOrder>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
分析SOAP 声明部分:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
...
</SOAP-ENV:Envelope>
这三个属性是必须的!!!!
第一个属性:
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
Actually, :Envelope and xmlns: are, but the use of the string SOAP-ENV is
completely arbitrary(任意的). What's really important is its relationship to the :Envelope and xmlns:
keywords.
其实这样也是可以地:
<abbr:Envelope
xmlns:abbr="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
...
</abbr:Envelope>
第二个属性:
xmlns:xsi=http://www.w3.org/1999/XMLSchema-instance
The prefix, xsi, must be prepended to all elements and attributes defined in this namespace
功能:declares the XML schema instance namespace
例如:xsi:type
第三个属性:
xmlns:xsd=http://www.w3.org/1999/XMLSchema
作用:defines the XMLSchema namespace
分析: The SOAP Header
a place to put directives to the SOAP processor that receives the message.
The <Body> is reserved purely for the method call and its parameters, and the <Header> is used for
things targeted at the underlying infrastructure, such as a transaction ID
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
<SOAP-ENV:Header>
<jaws:MessageHeader xmlns:jaws="urn:oreilly-jaws-samples">
<From>Me</From>
<To>You</To>
<MessageId>9999</MessageId>
...
</jaws:MessageHeader>
34
</SOAP-ENV:Header>
<SOAP-ENV:Body>
...
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
分析:The SOAP Protocol Binding
SOAPAction = "urn:soaphttpclient-action-uri"
Host = localhost
Content-Type = text/xml; charset=utf-8
Content-Length = 701
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">
...
</SOAP-ENV:Envelope>
- SOAP学习笔记(1)
- SOAP学习笔记
- SOAP 学习笔记
- soap学习笔记(一)
- SOAP/Web Service学习笔记
- WebService学习笔记之SOAP
- EJB3.0学习笔记--SOAP-AXIS--深入Soap引擎
- CXF 2.0 学习笔记-3 SOAP Header
- SOAP笔记
- SOAP学习
- SOAP学习
- SOAP学习
- soap学习
- SOAP学习
- soap学习
- c# Web Services学习笔记(一、SOAP协议概述)
- c# Web Services学习笔记(二、SOAP消息)
- c# Web Services学习笔记(三、SOAP消息交换模型)
- CMFCRibbonBar及其他Ribbon类的使用
- 浅谈运动有益于健康
- Android:SMS TEL MAIL 使用集合
- 利用VC访问INI文件和系统注册表
- SQL--子查询(6) [略]
- SOAP 学习笔记
- 教你如何注册DLL或OCX文件
- Linux route 中rt_hash 源码(转)
- C语言通用双向链表的实现--设计的艺术
- 常见的三种中文内码转换代码
- 说说益于健康的健身舞与健身操
- 关于C语言通用双向链表实现的测试--回调函数的作用
- SQL--操作数据(7)
- SQL--操作和创建表(8)