SOAP re-declaring qname inside body

99封情书 提交于 2019-12-11 11:51:52

问题


I have a SOAP request of this form:

<soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:myqname="http://example.com/hello" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header/>
   <soapenv:Body>
      <myqname:MyRequest xmlns:myqname="http://example.com/hello">
         ...
      </myqname:MyRequest>
   </soapenv:Body>
</soapenv:Envelope>

If I ask SOAPUI to "Format XML" this request, it removes the second declaration of myqname, so I get this:

<soapenv:Envelope 
      xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
      xmlns:myqname="http://example.com/hello" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header/>
   <soapenv:Body>
      <myqname:MyRequest>
         ...
      </myqname:MyRequest>
   </soapenv:Body>
</soapenv:Envelope>

The original request works fine, but the Application Servers fails with the modified request with this error:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Client</faultcode>
         <faultstring>Unmarshalling Error: UndeclaredPrefix: Cannot resolve 'myqname:MyRequest' as a QName: the prefix 'myqname' is not declared.</faultstring>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

According to the web services specification, is it mandatory for the qname to be re-declared inside the soapenv:Body node? Is this a SOAPUI bug, or an Application Server bug? or a misunderstanding from my part?

SOAPUI 4.0.1, WebLogic Server Version: 10.3.2.0

Edit: ups, even if using WebLogic application server, I was using the CXF web services framework. I posted the issue there. issues.apache.org/jira/browse/CXF-4026

So: SOAPUI 4.0.1, CXF 2.5.0


回答1:


I'd describe it as a bug in the code that strips the SOAP envelope; it should preserve the namespace context yet it isn't doing so, and that's breaking the XML. I guess that's because it is doing the stripping by taking a substring rather than operating at the DOM element level (whether or not it's using DOM processing to do the stripping is beside the point). I'm not sure which component is doing that stripping because of the way these things can be nested, but I suspect it's WebLogic…


[EDIT]: I've checked the SOAP specification and it does not say that the contents of the body has to directly declare the namespace used (see §5.3.1), though it does say that it SHOULD be namespaced. Because of that, normal XML namespacing rules apply — the whole SOAP message is simply an XML document — and that would make WebLogic's behavior a bug.



来源:https://stackoverflow.com/questions/8819989/soap-re-declaring-qname-inside-body

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!