soap协议版本引发的血案

    利用HTTP+POST发送基于SOAP协议的XML,总是报错 Transport level information does not match with SOAP Message namespace URI;看上去是找不到命名空间,穷尽各种办法,不能解决。然后重新看了一遍SOAP协议规范也未见成果。最后,意外中找到了SOAP的英文说明文档,其中描述:

Using SOAP Namespace
Every XML message contains namespaces to properly qualify the entities within it. In SOAP 1.1 and SOAP 1.2 specifications, each had defined its own unique namespaces to define the entities belonging to those specifications.
 
SOAP 1.1 : http://schemas.xmlsoap.org/soap/envelope/
 
SOAP 1.2 : http://www.w3.org/2003/05/soap-envelope
 
This is the easiest and sometimes the only method some people use. You can look at the SOAP namespace of a SOAP message and easily determine its version.
 
 
http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsd=" http://www.w3.org/2001/XMLSchema"
    xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
   
        .........
   
   
        ....
   
SOAP 1.1 message
 
You might argue that this is the only method you need to know to differentiate two different SOAP versions. This might not be the case all the time. For example, there can be a situation where you will need to know the SOAP version even before reading the SOAP message itself. Even though the previous statement seems unusual, this is how it is when we have two different object models or two different builders for the two SOAP versions. In such situations, as a developer, you cannot afford to touch the SOAP message to find out the version. Perhaps you can cheat by temporarily recording the first few events or entities, but that might not be the best solution.
 
In the next section, we will use transport binding rules, if available, to differentiate between the two different versions.

看完此段,才知SOAP协议现在又1.2和1.1两个版本,之前一直以为一个。。。。然后又发现了。。。
A: When Apache Axis2/Java receives a SOAP message, Axis2 tries to determine the SOAP version this message adheres to. This is required for the validation purposes against the correct SOAP specification. Axis2 has two basic mechanisms to identify the SOAP version.
 
1. Checking the namespace of the SOAP envelope. If the namespace is " http://schemas.xmlsoap.org/soap/envelope/", then it is a SOAP 1.1 message, and if the namespace is " http://www.w3.org/2003/05/soap-envelope", then it is a SOAP 1.2 message.
 
2.If the transport medium is HTTP, Then we check for the existance of SOAPAction HTTP Header. If the message is SOAP 1.1, then there must be a SOAPAction HTTP header. If it is a SOAP 1.2 message, then there may be a SOAPAction parameter inside the Content-type header (this parameter is not mandatory according to SOAP 1.2 specification HTTP binding)
 
When both the above parameters are present, Axis2 compares the outputs from those evaluations. If they do not match, then Axis2 will throw an error saying " Transport level information does not match with SOAP Message namespace URI". So if you encounter this error, check your SOAP message and HTTP headers.
 
看完此段恍然大悟。。。遇到的问题正如黑体字描述所说,然后:
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/".
问题得以解决。 
 

感谢初中英语老师,感谢高中英语老师,感谢大学英语老师。 
 

 

你可能感兴趣的:(WebService)