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

SOAPFaultException built programmatically and thrown in a JAX-WS handler are not correctly populated

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.1
    • 2.0.5, 2.1
    • JAX-WS Runtime
    • None
    • whatever

    • Moderate

    Description

      Create a SOAPFaultException filled with a SOAPFault and throw it from a JAX-WS Hander.
      On the other side some content of the SOAPFaultException is missing.

      Here is a code that can be tried: create a SOAPHandler with the following handleMessage().

      public boolean handleMessage(SOAPMessageContext ctx) {
      Boolean outboundProperty = (Boolean) ctx
      .get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);

      if (!outboundProperty) {
      SOAPMessage msg = ctx.getMessage();
      SOAPBody body;
      try

      { body = msg.getSOAPBody(); SOAPFault fault = body.addFault(); QName faultName = new QName(SOAPConstants.URI_NS_SOAP_ENVELOPE, "Server"); fault.setFaultCode(faultName); fault.setFaultActor("http://gizmos.com/orders"); fault.setFaultString("Server not responding"); Detail detail = fault.addDetail(); QName entryName = new QName("http://gizmos.com/orders/", "order", "PO"); DetailEntry entry = detail.addDetailEntry(entryName); entry.addTextNode("Quantity element does not have a value"); QName entryName2 = new QName("http://gizmos.com/orders/", "order", "PO"); DetailEntry entry2 = detail.addDetailEntry(entryName2); entry2.addTextNode("Incomplete address: no zip code"); throw new SOAPFaultException(fault); }

      catch (SOAPException e)

      { // TODO Auto-generated catch block e.printStackTrace(); }

      }

      return true;
      }

      This is what I would expect:

      <soapenv:Fault>
      <faultcode>soapenv:Server</faultcode>
      <faultstring>Server not responding</faultstring>
      <faultactor>http://gizmos.com/orders</faultactor>
      <detail>
      <PO:order xmlns:PO="http://gizmos.com/orders/">Quantity element does not have a value</PO:order>
      <PO:order xmlns:PO="http://gizmos.com/orders/">Incomplete address: no zip code</PO:order>
      </detail>
      </soapenv:Fault>

      And this is what I get:

      <soap:Fault>
      <faultcode>soap:Server</faultcode>
      <faultstring>Server not responding</faultstring>
      </soap:Fault>

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            dgesino Davide Gesino
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: