axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Thomas (JIRA)" <>
Subject [jira] [Commented] (AXIS2-5786) MessageContextBuilder - createFaultEnvelope - FaultCode with "soapenv" prefix and different namespace from envelope causes error
Date Tue, 14 Jun 2016 22:48:30 GMT


Jeff Thomas commented on AXIS2-5786:

Hallo Andreas,

yessir, that sounds like the same problem!

That change has been untouched for just about 4 years though.

I have revised my current workaround by using:

instead of:

In this case, the QName constant does *not* have a prefix defined (the prefix is null) and
a new prefix is generated / assigned.

To be honest, I can't figure out where the implementation code went for "org/apache/axiom/om/impl/llom/"
went :) but the older revisions use a deprecated method (documented as the "last gasp approach")

> MessageContextBuilder - createFaultEnvelope - FaultCode with "soapenv" prefix and different
namespace from envelope causes error
> --------------------------------------------------------------------------------------------------------------------------------
>                 Key: AXIS2-5786
>                 URL:
>             Project: Axis2
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.7.3
>            Reporter: Jeff Thomas
>             Fix For: 1.7.4, 1.8.0
> I have encountered a problem in MessageContextBuilder.createFaultEnvelope(MessageContext,
Throwable) where the throwable is an AxisFault with the default SOAP namespace prefix but
a *different* namespace-URI than the envelope itself.  For example, including a fault-code
with a SOAP 1.2 namespace in a SOAP 1.1 envelope or a fault-code SOAP 1.1 namespace in a SOAP
1.2 envelope.
> The result in at least the first case is the following error:
> "A Soap envelope with fault action - has
been received without a fault element in the soap body"
> The precondition is that the fault code content has the same namespace prefix as the
SOAP element being created.
> {code:xml}
> <faultcode>soapenv:Receiver</faultcode>
> {code}
> The cause of the error is that the prefix within the fault code is used to declare a
namespace on the "soapenv:Fault" element.  This results in two different namespace URIs being
declared with the same prefix:
> {code:xml}
> <?xml version='1.0' encoding='utf-8'?>
> <soapenv:Envelope xmlns:soapenv="">
>   <soapenv:Header/>
>   <soapenv:Body>
>     <soapenv:Fault xmlns:soapenv="">
>       <faultcode>soapenv:Receiver</faultcode>
>       <faultstring>Hello World!</faultstring>
>     </soapenv:Fault>
>   </soapenv:Body>
> </soapenv:Envelope>
> {code}
> During debugging you can clearly see the problem with the double prefix:
> {code:xml}
> <soapenv:Fault xmlns:soapenv="" xmlns:soapenv="">
>   <faultcode>soapenv:Receiver</faultcode>
>   <faultstring>General error in function getStructure.</faultstring>
> </soapenv:Fault>
> {code}
> *The real problem is most-likely in Axiom OMElement implementation.*(???).  The OMElement
declareNamespace method does not check if the given prefix is identical to that of the OMElement
itself (with a different namespace URI).  In this case, it should probably discard the provided
prefix and generate a new one.  I created a simple example of this problem which creates an
element with prefix "foo" and a given namespace URI and then declares a second namespace on
this element with the same prefix and a different URI.  The result is an OMElement with a
> {code:java}
> import;
> import;
> import;
> import;
> public class NamespaceTest {
>   final static String NS_URI_1 = "";
>   final static String NS_URI_2 = "";
>   final static String NS_PFX = "foo";
>   public static void main (String[] args) {
>     final OMFactory omFactory = OMAbstractFactory.getOMFactory();
>     OMElement testElement = omFactory.createOMElement("testElement", NS_URI_1, NS_PFX);
>     testElement.declareNamespace(NS_URI_2, NS_PFX);
>     try {
>       testElement.serialize(System.out);
>     } catch (XMLStreamException ex) {
>       System.err.println("Unable to serialize the OMElement. Reason: " + ex.getMessage());
>     }
>   }
> }
> {code}
> This method generates the following output:
> {code:xml}
> <foo:testElement xmlns:foo="" xmlns:foo=""/>
> {code}
> Our workaround at the moment is that we no longer use the default *SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX*
(== 'soapenv'*) constant for our custom Axis-Fault.  For example "foo":
> {code:xml}
> <soapenv:Fault xmlns:soapenv="" xmlns:foo="">
>   <faultcode>foo:Receiver</faultcode>
>   <faultstring>General error in function getStructure.</faultstring>
> </soapenv:Fault>
> {code}
> Nonetheless, I wanted to file the issue here because the double-prefix problem can occur
on any OMElement.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message