JBoss WS CXF misses Subcode in SOAP 1.2 SOAPFault

Solution Verified - Updated -

Issue

  • We are trying to throw a SOAP 1.2 Fault with Subcode like the following on EAP 6 with JBoss WS CXF stack:

    <S:Body>
      <S:Fault xmlns:ns4="http://schemas.xmlsoap.org/soap/envelope/">
        <S:Code>
          <S:Value>S:Sender</S:Value>
          <S:Subcode>
            <S:Value xmlns:ns1="...">ns1:OperatorNotFound</S:Value>
          </S:Subcode>
        </S:Code>
        <S:Reason>
          <S:Text xml:lang="en">Operator not found</S:Text>
        </S:Reason>
        <S:Detail> ... </S:Detail>
      </S:Fault>
    </S:Body>
    

    However, we couldn't succeed when throwing a custom checked exception like below:

    @WebFault(name = "...", targetNamespace = "...")
    public class CustomException extends Exception {
        private CustomFaultInfo faultInfo;
        public CustomException(String message, CustomFaultInfo faultInfo) {
            super(message);
            this.faultInfo = faultInfo;
        }
        public CustomException(String message, CustomFaultInfo faultInfo, Throwable cause) {
            super(message, cause);
            this.faultInfo = faultInfo;
        }
        public CustomFaultInfo getFaultInfo() { return faultInfo; }
    }
    
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "...", propOrder = {"code", "subCode" })
    public class CustomFaultInfo {
        @XmlElement(name = "Code", required = true)
        protected QName code;
        @XmlElement(name = "SubCode")
        protected List<QName> subCode;
    
        public QName getCode() { return code; }
        public void setCode(QName value) { this.code = value; }
        public List<QName> getSubCode() {
            if (subCode == null) {
                subCode = new ArrayList<QName>();
            }
            return this.subCode;
        }
    }
    

    How can I achieve that? Or, is that a bug?

  • I'm trying to include both a SOAP fault detail (using the JAX-WS getFaultInfo() convention) and a subcode in my SOAP fault, but I can't seem to get it to work.

Environment

  • JBoss Enterprise Application Platform (EAP)
    • 5.x + JBoss WS CXF
    • 6.0.x
  • JBoss Enterprise SOA Platform (SOA-P)
    • 5.x + JBoss WS CXF

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content