• SOAP1.1 VS SOAP1.2


     SOAP提升:

    目前WebService的协议主要有SOAP1.1和1.2。
    两者的命名空间不同。

    见下页对比

    SOAP1.1版本与SOAP1.2版本在头信息上存在差异。
    SOAP1.1存在SOAPAction的请求头。
    SOAP1.2没有SOAPAction的请求头。
    基于SOAP1.1生成的WSDL和基于SOAP1.2生成的WSDL也不一样。

    主要看命名空间


    在CXF中两种协议请求的方式也不一样。
    1.1为content-Type:text/xm;charset=UTF-8
    1.2为content-Type:application/soap+xml;charset=UTF-8

    命名空间:

    Soap1.1的命名空间:

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

    Soap1.2 命名空间:

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

    SOAP1.1的HTTP请求头:

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

    注意上面包含SOAPAction且请求方式为text/xml。

    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

    注意上面没有SOAPAction且类型为soap+xml.

    SOAP1.1和1.2的WSDL文件的差别:

    在定义Service部分差别如下:
    Soap1.1是以:soap:address定义。
    Soap1.2是以: soap12:address定义。-jdk1.6不支持12形式的访问。

    通过BindingType将项目转到1.2:

    在类上面添加以下注解可以使用soap1.2的协议:

    @BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)
    或在applicationContext.xml中使用binding
    <jaxws:binding>
    <soap:soapBinding version="1.2" />
    </jaxws:binding>

    SOAP1.2的调用:

    当使用了SOAP12以后,wsimport和Eclipse的WSExplorer都不可以正常使用了。
    必须,使用cxf提供的wsdl2java工具生成本地代码。
    生成本地代码后,通过cxf内置的拦截器,拦截到以下头信息说明是soap12.

    SOAP11与SOAP12的调用关系:

    CXF中两种协议请求的方式也不一样 

    Soap1.1以普通方式访问:

    使用JaxWsProxyFactoryBean

    Soap1.2以指定wsdl地址和命名空间的形式访问:

    Service service = Service.create(new URL(“wsdlUrl”),
    new QName(“namespace”,”ServiceName”));
    SomeClass sc = service.getPort(new QName(“namespace”,”PortName”),
    SomeClass.class);
    sc.someMethod(someParam);

    通过Ajax形式访问:

    1、指定contentType:’application/soap+xml;charset=“UTF-8”‘
    2、组织使用XML数据,使用SOAP12的命名空间.
    (由于代码太多,请见下面的备注)
  • 相关阅读:


    django 认证系统--3
    django 认证系统--2
    django 认证系统--1


    关于二叉树
    [GeeksForGeeks] Remove all half nodes of a given binary tree
    [LintCode] Letter Combinations of a Phone Number
  • 原文地址:https://www.cnblogs.com/biaogejiushibiao/p/10351276.html
Copyright © 2020-2023  润新知