Soap1.1和Soap1.2的區別

WebService經過HTTP協議完成遠程調用: (深刻分析) – RPC java

WebService只採用HTTP POST方式傳輸數據,不使用GET方式; -- 握手,WSDL-get, web

•普通http post的contentType爲 spring

•application/x-www-form-urlencoded app

•WebService的contentType爲-即在Http的基礎上發SOAP協議 post

•text/xml 這是基於soap1.1協議。 編碼

•application/soap+xml 這是基於soap1.2協議。url

WebService從數據傳輸格式上做了限定。WebService所使用的數據均是基於XML格式的。目前標準的WebService在數據格式上主要採用SOAP協議。SOAP協議實際上就是一種基於XML編碼規範的文本協議。 spa

SOAP – Simple Object Access protocol 簡單對像訪問協議。是運行在HTTP協議基礎之上的協議。其實就是在HTTP協議是傳輸XML文件,就變成了SOAP協議。目前SOAP的版本主要有SOAP1.1和SOAP1.2。 code

SOAP1.1和SOAP1.2的namespace不同。 orm

Soap1.1命名空間:

xmlns:soap=「http://schemas.xmlsoap.org/soap/envelope/「

Soap1.2 命名空間:

xmlns:soap="http://www.w3.org/2003/05/soap-envelope

能夠經過查看類

•javax.xml.ws.soap.SOAPBinding來查看裏面的常量

•默認狀況下,Jdk1.6只支持soap1.1

•即:@BindingType(value=javax.xml.ws.soap.SOAPBinding.SOAP11HTTP_BINDING)

jdk1.6默認不支持12形式的訪問。SOAP提高:

經過BindingType將項目轉到1.2

在類上面添加如下註解能夠使用soap1.2的協議:

•@BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)

或在applicationContext.xml中使用binding

•<</SPAN>jaxws:binding>

• <</FONT>soap:soapBindingversion="1.2" />

• </</FONT>jaxws:binding>

3.SOAP1.1版本與SOAP1.2版本在頭信息上存在差別。

1.SOAP1.1存在SOAPAction的請求頭。

2.SOAP1.2沒有SOAPAction的請求頭。

4.SOAP1.1和1.2的WSDL文件的差異:

1.主要看命名空間。

2.在定義Service部分差異以下:

Soap1.1是以:soap:address定義。

Soap1.2是以: soap12:address定義。-jdk1.6不支持12形式的訪問。

5.在CXF中兩種協議請求的方式也不同。

1.SOAP1.1爲content-Type:text/xm;charset=UTF-8

2.SOAP1.2爲content-Type:application/soap+xml;charset=UTF-8

SOAP1.1的HTTP請求頭:

POST /xe_cxf2.4_soap12_spring_web/ws/helloworldsoap12?wsdl HTTP/1.1
Content-Type: text/xml; charset=UTF-8
Accept: **
User-Agent: Apache CXF 2.4.0
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:6767
Connection: keep-alive
Content-Length: 214

SOAP1.2的請求頭:

POST /xe_cxf2.4_soap12_spring_web/ws/helloworldsoap12?wsdl HTTP/1.1
Content-Type: application/soap+xml;charset=UTF-8
Accept: */*
User-Agent: Apache CXF 2.4.0
Cache-Control: no-cache
Pragma: no-cache
Host: localhost:6767
Connection: keep-alive
Content-Length: 214

 

SOAP1.1 request and SOAP1.2 request:

SOAP 1.1 Request:

POST /WSShakespeare.asmx HTTP/1.1
Host: www.xmlme.com 
Content-Type: text/xml; charset=utf-8
Content-Length: length 
SOAPAction: "http://xmlme.com/WebServices/GetSpeech"
 
<?xml version="1.0" encoding="utf-8"?> 
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> 
  <soap:Body> 
    <GetSpeech xmlns="http://xmlme.com/WebServices"> 
      <Request>string</Request> 
    </GetSpeech> 
  </soap:Body> 
</soap:Envelope>

SOAP1.2 Request:

POST /WSShakespeare.asmx HTTP/1.1
Host: www.xmlme.com 
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length 
 
<?xml version="1.0" encoding="utf-8"?> 
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"> 
  <soap12:Body> 
    <GetSpeech xmlns="http://xmlme.com/WebServices"> 
      <Request>string</Request> 
    </GetSpeech> 
  </soap12:Body> 
</soap12:Envelope>

Differences between SOAP1.1 and  SOAP1.2:

  • SOAP 1.2 uses 「application/soap+xml」 as Content-Type and SOAP 1.1 uses 「text/xml」.
  • SOAP 1.2 does not use SOAPAction header line.
  • SOAP 1.2 uses 「http://www.w3.org/2003/05/soap-envelope」 as the envolope namespace and SOAP 1.1 uses 「http://schemas.xmlsoap.org/soap/envelope/」
相關文章
相關標籤/搜索