soap

SOAP协议简介  

什么是SOAP  
SOAP 指简单对象访问协议,它是一种基于XML的消息通讯格式,用于网络上,不同平台,不同语言的应用程序间的通讯。可自定义,易于扩展。一条 SOAP 消息就是一个普通的 XML 文档,包含下列元素: 
• Envelope 元素,标识XML 文档一条 SOAP 消息 
• Header 元素,包含头部信息的XML标签 
• Body 元素,包含所有的调用和响应的主体信息的标签 

• Fault 元素,错误信息标签。


以上的元素都在 SOAP的命名空间http://www.w3.org/2001/12/soap-envelope中声明; 
SOAP的语法规则 
• SOAP 消息必须用 XML 来编码 
• SOAP 消息必须使用 SOAP Envelope 命名空间 
• SOAP 消息必须使用 SOAP Encoding 命名空间 
• SOAP 消息不能包含 DTD 引用 
• SOAP 消息不能包含 XML 处理指令 

SOAP 消息的基本结构 

Java代码 
  1. <? xml version="1.0"?>   
  2. <soap:Envelope   
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"  
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">   
  5. <soap:Header>   
  6.   ...   
  7.   ...   
  8. </soap:Header>   
  9. <soap:Body>   
  10.   ...   
  11.   ...   
  12.   <soap:Fault>   
  13.     ...   
  14.     ...   
  15.   </soap:Fault>   
  16. </soap:Body>   
  17. </soap:Envelope>  
    1. <? xml version="1.0"?>  
    2. <soap:Envelope  
    3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"  
    4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">  
    5. <soap:Header>  
    6.   ...  
    7.   ...  
    8. </soap:Header>  
    9. <soap:Body>  
    10.   ...  
    11.   ...  
    12.   <soap:Fault>  
    13.     ...  
    14.     ...  
    15.   </soap:Fault>  
    16. </soap:Body>  
    17. </soap:Envelope>  
      



  1. <? xml version="1.0"?>  
  2. <soap:Envelope  
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"  
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">  
  5. <soap:Header>  
  6.   ...  
  7.   ...  
  8. </soap:Header>  
  9. <soap:Body>  
  10.   ...  
  11.   ...  
  12.   <soap:Fault>  
  13.     ...  
  14.     ...  
  15.   </soap:Fault>  
  16. </soap:Body>  
  17. </soap:Envelope>  
SOAP Envelope 元素  
Envelope 元素是 SOAP 消息的根元素。它指明 XML 文档是一个SOAP 消息。它的属性 xmlns:soap的值必须是http://www.w3.org/2001/12/soap-envelope。 
 encodingStyle 属性,语法:soap:encodingStyle="URI" 
encodingStyle 属性用于定义文档中使用的数据类型。此属性可出现在任何 SOAP 元素中,并会被应用到元素的内容及元素的所有子元素上。 
Java代码  复制代码
  1. <? xml version="1.0"?>   
  2. <soap:Envelope   
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"  
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">   
  5.   ...   
  6.   Message information goes here   
  7.   ...   
  8. </soap:Envelope>  
[java]  view plain copy
  1. <? xml version="1.0"?>  
  2. <soap:Envelope  
  3. xmlns:soap="http://www.w3.org/2001/12/soap-envelope"  
  4. soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">  
  5.   ...  
  6.   Message information goes here  
  7.   ...  
  8. </soap:Envelope>  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值