WSDL可以指示Web服务的SOAP版本(1.1或1.2)吗?

mjn*_*mjn 71 soap wsdl web-services

是否可以根据WSDL中的信息查看Web服务是否使用SOAP 1.1或1.2?

jmh*_*let 64

SOAP 1.1使用命名空间http://schemas.xmlsoap.org/wsdl/soap/

SOAP 1.2使用命名空间http://schemas.xmlsoap.org/wsdl/soap12/

wsdl能够在同一个wsdl中同时在soap 1.1和soap 1.2下定义操作.如果您需要改进wsdl以支持需要soap 1.2(例如MTOM)的新功能,那么这很有用,在这种情况下,您不需要创建新服务,而只需要改进原始服务.

  • MTOM可与soap1.1一起使用 (3认同)

Cha*_*oon 33

在WSDL中,如果你看一下Binding部分,你会清楚地看到如果服务使用soap 1.2,就会明确提到soap绑定.参考以下样本.

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="findEmployeeById">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation><operation name="create">
    <soap12:operation soapAction=""/>
    <input><soap12:body use="literal"/></input>
    <output><soap12:body use="literal"/></output>
</operation>
</binding>
Run Code Online (Sandbox Code Playgroud)

如果Web服务使用soap 1.1,它将不会在绑定部分下的WSDL文件中显式定义任何soap版本.参考以下样本.

<binding name="EmployeeServiceImplPortBinding" type="tns:EmployeeServiceImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"/>
<operation name="findEmployeeById">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation><operation name="create">
    <soap:operation soapAction=""/>
    <input><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></input>
    <output><soap:body use="literal" namespace="http://jaxb.ws.jax.samples.chathurangaonline.com/"/></output>
</operation>
</binding>
Run Code Online (Sandbox Code Playgroud)

如何确定SOAP消息的SOAP版本?

但请记住,这不是推荐的方法来确定您的Web服务使用的soap版本.可以使用以下方法之一确定soap消息的版本.

1.检查soap消息的命名空间

SOAP 1.1  namespace : http://schemas.xmlsoap.org/soap/envelope

SOAP 1.2 namespace  : http://www.w3.org/2003/05/soap-envelope
Run Code Online (Sandbox Code Playgroud)

2.检查soap消息的传输绑定信息(http头信息)

SOAP 1.1:Context-Type的用户text/xml

   POST /MyService HTTP/1.1
   Content-Type: text/xml; charset="utf-8"
   Content-Length: xxx
   SOAPAction: "urn:uuid:myaction"
Run Code Online (Sandbox Code Playgroud)

SOAP 1.2:Context-Type的用户应用程序/ soap + xml

   POST /MyService HTTP/1.1
   Content-Type: application/soap+xml; charset="utf-8"
   Content-Length: xxx
   SOAPAction: "urn:uuid:myaction"
Run Code Online (Sandbox Code Playgroud)

3.使用SOAP故障信息

两个版本之间的SOAP错误消息的结构是不同的.

  • 你的答案的第一部分可以使用一些额外的信息 - "soap12"是命名空间前缀,而不是命名空间本身.您需要检查"soap12"前缀解析的内容以及指定的soap版本.有人可以使用soap12作为前缀,但指向soap11名称空间URI. (12认同)
  • @csadler 的评论非常重要,但即使如此,也没有提供正确的命名空间值。给你。引用 1.1 的“soap”前缀是“http://schemas.xmlsoap.org/wsdl/soap/”。引用 1.2 的“soap12”前缀是“http://schemas.xmlsoap.org/wsdl/soap12/”。无论前缀名称是什么(甚至可以是“foo”或“bar”),只需查看它解析的名称空间即可。 (2认同)

mjn*_*mjn 13

我找到了这个页面

http://schemas.xmlsoap.org/wsdl/soap12/soap12WSDL.htm

说Soap 1.2使用新命名空间http://schemas.xmlsoap.org/wsdl/soap12/

它位于"SOAP 1.1的WSDL 1.1绑定扩展"中.


sip*_*wiz 6

是的,您通常可以根据 WSDL 查看支持什么 SOAP 版本。

看一下演示 Web 服务 WSDL。它有一个对soap12命名空间的引用,表明它支持SOAP 1.2。如果不存在,那么假设该服务仅支持 SOAP 1.1,您可能是安全的。