axis-java-dev mailing list archives

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

    [ https://issues.apache.org/jira/browse/AXIS2-5786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15330775#comment-15330775
] 

Andreas Veithen commented on AXIS2-5786:
----------------------------------------

That's probably one of the cases envisaged in AXIOM-376.

> MessageContextBuilder - createFaultEnvelope - FaultCode with "soapenv" prefix and different
namespace from envelope causes error
> --------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AXIS2-5786
>                 URL: https://issues.apache.org/jira/browse/AXIS2-5786
>             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 -http://www.w3.org/2005/08/addressing/soap/fault 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="http://schemas.xmlsoap.org/soap/envelope/">
>   <soapenv:Header/>
>   <soapenv:Body>
>     <soapenv:Fault xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>       <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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>   <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
double-prefix:
> {code:java}
> import javax.xml.stream.XMLStreamException;
> import org.apache.axiom.om.OMAbstractFactory;
> import org.apache.axiom.om.OMElement;
> import org.apache.axiom.om.OMFactory;
> public class NamespaceTest {
>   final static String NS_URI_1 = "http://www.foobar.org/2005";
>   final static String NS_URI_2 = "http://www.foobar.org/2009";
>   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="http://www.foobar.org/2005" xmlns:foo="http://www.foobar.org/2009"/>
> {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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:foo="http://www.w3.org/2003/05/soap-envelope">
>   <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
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@axis.apache.org
For additional commands, e-mail: java-dev-help@axis.apache.org


Mime
View raw message