【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

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值