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 D30E8200C4D for ; Wed, 5 Apr 2017 21:15:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D1A3F160B9E; Wed, 5 Apr 2017 19:15:52 +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 2542F160B94 for ; Wed, 5 Apr 2017 21:15:51 +0200 (CEST) Received: (qmail 60451 invoked by uid 500); 5 Apr 2017 19:15:51 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 60366 invoked by uid 99); 5 Apr 2017 19:15:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Apr 2017 19:15:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 2AF46DFBA4; Wed, 5 Apr 2017 19:15:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkulp@apache.org To: commits@cxf.apache.org Date: Wed, 05 Apr 2017 19:15:51 -0000 Message-Id: <33d455e0ef86416590b77905ca3b9574@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/2] cxf git commit: [CXF-6919] For soap 1.2, make sure the fault code is valid archived-at: Wed, 05 Apr 2017 19:15:53 -0000 [CXF-6919] For soap 1.2, make sure the fault code is valid Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/29af9d48 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/29af9d48 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/29af9d48 Branch: refs/heads/master Commit: 29af9d48cee34521fcc9bc27a79d15f5781916a9 Parents: 60d2577 Author: Daniel Kulp Authored: Wed Apr 5 11:29:05 2017 -0400 Committer: Daniel Kulp Committed: Wed Apr 5 14:49:11 2017 -0400 ---------------------------------------------------------------------- .../apache/cxf/binding/soap/saaj/SAAJUtils.java | 39 +++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/29af9d48/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java ---------------------------------------------------------------------- diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java index c29af06..96a1701 100644 --- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java +++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJUtils.java @@ -21,12 +21,14 @@ package org.apache.cxf.binding.soap.saaj; import javax.xml.namespace.QName; import javax.xml.soap.SOAPBody; +import javax.xml.soap.SOAPConstants; import javax.xml.soap.SOAPElement; import javax.xml.soap.SOAPException; import javax.xml.soap.SOAPFault; import javax.xml.soap.SOAPHeader; import javax.xml.soap.SOAPMessage; +import org.apache.cxf.binding.soap.Soap12; import org.apache.cxf.common.util.StringUtils; /** @@ -52,24 +54,33 @@ public final class SAAJUtils { return m.getSOAPPart().getEnvelope().getBody(); } } + public static void setFaultCode(SOAPFault f, QName code) throws SOAPException { - try { - f.setFaultCode(code); - } catch (Throwable t) { - int count = 1; - String pfx = "fc1"; - while (!StringUtils.isEmpty(f.getNamespaceURI(pfx))) { - count++; - pfx = "fc" + count; + if (f.getNamespaceURI().equals(Soap12.SOAP_NAMESPACE)) { + try { + f.setFaultCode(code); + } catch (SOAPException ex) { + f.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT); + f.appendFaultSubcode(code); } - if (code.getNamespaceURI() != null && !"".equals(code.getNamespaceURI())) { - f.addNamespaceDeclaration(pfx, code.getNamespaceURI()); - } else { - f.addNamespaceDeclaration(pfx, f.getNamespaceURI()); + } else { + try { + f.setFaultCode(code); + } catch (Throwable t) { + int count = 1; + String pfx = "fc1"; + while (!StringUtils.isEmpty(f.getNamespaceURI(pfx))) { + count++; + pfx = "fc" + count; + } + if (code.getNamespaceURI() != null && !"".equals(code.getNamespaceURI())) { + f.addNamespaceDeclaration(pfx, code.getNamespaceURI()); + } else { + f.addNamespaceDeclaration(pfx, f.getNamespaceURI()); + } + f.setFaultCode(pfx + ":" + code.getLocalPart()); } - f.setFaultCode(pfx + ":" + code.getLocalPart()); } - } public static SOAPElement adjustPrefix(SOAPElement e, String prefix) {