Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4535

SOAP fault XML is invalid when a details element exists

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.6.2
    • 2.4.10, 2.5.6, 2.6.3, 2.7
    • None
    • None
    • Unknown

    Description

      If you add a details element to a SOAP fault, you will get invalid XML.

      For example, this code:

      final SoapFault fault = new SoapFault(shortMessage, Soap11.getInstance().getReceiver());
      fault.setRole(operationName);
      final org.w3c.dom.Element detailElt = fault.getOrCreateDetail();
      final Document ownerDocument = detailElt.getOwnerDocument();
      final org.w3c.dom.Element longDescElt = ownerDocument.createElementNS(_TARGET_NAMESPACE, "longDescription");
      final org.w3c.dom.Element errorCodeElt = ownerDocument.createElementNS(_TARGET_NAMESPACE, "ErrorCode");
                  longDescElt.setTextContent(longMessage);
      

      Produces XML like:

      <?xml version='1.0' encoding='UTF-8'?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <ais:requestID xmlns:ais="http://com.seagullsw.appinterface/AppInterfaceServer">{c0a80102-00ce16ad0000010e75da25398002}</ais:requestID>
        </soap:Header>
        <soap:Body>
          <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>blah.</faultstring>
            <detail>
              <longDescription xmlns="http://com.seagullsw.appinterface/AppInterfaceServer">blah blah.</longDescription>
              <ErrorCode xmlns="http://com.seagullsw.appinterface/AppInterfaceServer">-7</ErrorCode>
            </detail>
            <faultactor>test.exception</faultactor>
          </soap:Fault>
        </soap:Body>
      </soap:Envelope>
      

      Instead of:

      <?xml version='1.0' encoding='UTF-8'?>
      <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
        <soap:Header>
          <ais:requestID xmlns:ais="http://com.seagullsw.appinterface/AppInterfaceServer">{c0a80102-00ce16ad0000010e75da25398002}</ais:requestID>
        </soap:Header>
        <soap:Body>
          <soap:Fault>
            <faultcode>soap:Server</faultcode>
            <faultstring>blah.</faultstring>
            <faultactor>test.exception</faultactor>
            <detail>
              <longDescription xmlns="http://com.seagullsw.appinterface/AppInterfaceServer">blah blah.</longDescription>
              <ErrorCode xmlns="http://com.seagullsw.appinterface/AppInterfaceServer">-7</ErrorCode>
            </detail>
          </soap:Fault>
        </soap:Body>
      </soap:Envelope>
      

      The detail element MUST be last.

      Attachments

        1. fix-invalid-soap-fault.diff
          1 kB
          Gary D. Gregory

        Activity

          People

            dkulp Daniel Kulp
            ggregory Gary D. Gregory
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: