Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 06F37200B33 for ; Wed, 15 Jun 2016 00:48:32 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 059AE160A56; Tue, 14 Jun 2016 22:48:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4B06A160A5F for ; Wed, 15 Jun 2016 00:48:31 +0200 (CEST) Received: (qmail 94404 invoked by uid 500); 14 Jun 2016 22:48:30 -0000 Mailing-List: contact java-dev-help@axis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@axis.apache.org Delivered-To: mailing list java-dev@axis.apache.org Received: (qmail 94375 invoked by uid 99); 14 Jun 2016 22:48:30 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Jun 2016 22:48:30 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 310032C1F5D for ; Tue, 14 Jun 2016 22:48:30 +0000 (UTC) Date: Tue, 14 Jun 2016 22:48:30 +0000 (UTC) From: "Jeff Thomas (JIRA)" To: java-dev@axis.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (AXIS2-5786) MessageContextBuilder - createFaultEnvelope - FaultCode with "soapenv" prefix and different namespace from envelope causes error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Tue, 14 Jun 2016 22:48:32 -0000 [ https://issues.apache.org/jira/browse/AXIS2-5786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15330803#comment-15330803 ] 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: {code:java} SOAP12Constants.QNAME_RECEIVER_FAULTCODE {code} instead of: {code:java} new QName(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, SOAP12Constants.FAULT_CODE_RECEIVER, SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX) {code} 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/OMElementImpl.java" went :) but the older revisions use a deprecated method (documented as the "last gasp approach") OMSerializerUtil.getNextNSPrefix(). > 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} > soapenv:Receiver > {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} > > > > > > soapenv:Receiver > Hello World! > > > > {code} > During debugging you can clearly see the problem with the double prefix: > {code:xml} > > soapenv:Receiver > General error in function getStructure. > > {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} > > {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} > > foo:Receiver > General error in function getStructure. > > {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