【WebService】Java WebService消息格式SOAP1.1和SOAP1.2的区别

摘要:

目前WebService的协议主要有SOAP1.1和1.2,CXF3的版本也同时支持1.1和1.2。

SOAP1.1和1.2发布的WebService的主要区别:

1、两者的命名空间不同。

1.1 -> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

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

注:这个地方只是说 xmlns:soap 这个标签

2、HTTP头信息上存在差异。

1.1 -> 为Content-Type: text/xml; charset=UTF-8

1.2 -> 为Content-Type: application/soap+xml;charset=UTF-8

3、发布的WSDL内容也不相同。

WSDL是Web Service的描述语言,版本不同,内容也就不尽相同了。

4、SOAP消息格式不同。

主要体现在消息格式的命名空间上。

SOAP1.1的消息格式:

1、HTTP调用参数

1

2

3

4

5

6

7

8

POST http://127.0.0.1:8080/CXF3/webservice/what21Hello HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: text/xml;charset=UTF-8

SOAPAction: ""

Content-Length: 288

Host: 127.0.0.1:8080

Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

2、请求的消息格式

1

2

3

4

5

6

7

8

9

10

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

          xmlns:cxf3="http://cxf3.what21.com/">

   <soapenv:Header/>

   <soapenv:Body>

      <cxf3:sayHi>

         <!--Optional:-->

         <text>?</text>

      </cxf3:sayHi>

   </soapenv:Body>

</soapenv:Envelope>

3、响应的消息格式

1

2

3

4

5

6

7

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

   <soap:Body>

      <ns2:sayHiResponse xmlns:ns2="http://cxf3.what21.com/">

         <return>?</return>

      </ns2:sayHiResponse>

   </soap:Body>

</soap:Envelope>

SOAP1.2的消息格式:

1、HTTP调用参数

1

2

3

4

5

6

7

POST http://127.0.0.1:8080/CXF3/webservice/what21Hello HTTP/1.1

Accept-Encoding: gzip,deflate

Content-Type: application/soap+xml;charset=UTF-8

Content-Length: 268

Host: 127.0.0.1:8080

Connection: Keep-Alive

User-Agent: Apache-HttpClient/4.1.1 (java 1.5)

2、请求的消息格式

1

2

3

4

5

6

7

8

9

10

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

         xmlns:cxf3="http://cxf3.what21.com/">

   <soap:Header/>

   <soap:Body>

      <cxf3:sayHi>

         <!--Optional:-->

         <text>?</text>

      </cxf3:sayHi>

   </soap:Body>

</soap:Envelope>

3、响应的消息格式

1

2

3

4

5

6

7

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

   <soap:Body>

      <ns2:sayHiResponse xmlns:ns2="http://cxf3.what21.com/">

         <return>?</return>

      </ns2:sayHiResponse>

   </soap:Body>

</soap:Envelope>

以上的内容,我们可以很直观的看到SOAP1.1和SOAP1.2的区别。

CXF3发布SOAP1.2的服务请参考:

http://www.what21.com/sys/view/java_webservice_1478011770049.html

参考文章

http://www.what21.com/sys/view/java_webservice_1478013505272.html

猜你喜欢

转载自blog.csdn.net/xiaoxiao_su123/article/details/111479626