Example usage for javax.xml.soap Detail getDetailEntries

List of usage examples for javax.xml.soap Detail getDetailEntries

Introduction

In this page you can find the example usage for javax.xml.soap Detail getDetailEntries.

Prototype

public Iterator<DetailEntry> getDetailEntries();

Source Link

Document

Gets an Iterator over all of the DetailEntry s in this Detail object.

Usage

From source file:com.legstar.proxy.invoke.jaxws.WebServiceInvoker.java

/**
 * Try to extract something meaningful from a SOAP Fault.
 * // w  w  w  .  j  a  v a 2  s . c om
 * @param e the SOAP Fault exception
 * @return a fault description
 */
@SuppressWarnings("rawtypes")
public String getFaultReasonText(final SOAPFaultException e) {
    if (_log.isDebugEnabled()) {
        SOAPFault fault = e.getFault();
        if (fault != null) {
            QName code = fault.getFaultCodeAsQName();
            String string = fault.getFaultString();
            String actor = fault.getFaultActor();
            _log.debug("SOAP fault contains: ");
            _log.debug("  Fault code = " + code.toString());
            _log.debug("  Local name = " + code.getLocalPart());
            _log.debug("  Namespace prefix = " + code.getPrefix() + ", bound to " + code.getNamespaceURI());
            _log.debug("  Fault string = " + string);
            if (actor != null) {
                _log.debug("  Fault actor = " + actor);
            }
            Detail detail = fault.getDetail();
            if (detail != null) {
                Iterator entries = detail.getDetailEntries();
                while (entries.hasNext()) {
                    DetailEntry newEntry = (DetailEntry) entries.next();
                    String value = newEntry.getValue();
                    _log.debug("  Detail entry = " + value);
                }
            }
        } else {
            _log.debug(e);
        }
    }
    SOAPFault fault = e.getFault();
    if (fault != null) {
        StringBuffer faultMessage = new StringBuffer(e.getFault().getFaultString());
        Detail detail = fault.getDetail();
        if (detail != null) {
            Iterator entries = detail.getDetailEntries();
            while (entries.hasNext()) {
                DetailEntry newEntry = (DetailEntry) entries.next();
                faultMessage.append(" [" + newEntry.getValue() + "]");
            }
        }
        return faultMessage.toString();
    } else {
        return e.getMessage();
    }

}

From source file:org.pentaho.platform.plugin.action.xmla.XMLABaseComponent.java

/**
 * check SOAP reply for Error, return fault Code
 *
 * @param reply   the message to check/*from   w w  w. ja v  a  2s  .  co  m*/
 * @param aReturn ArrayList containing faultcode,faultstring,faultactor
 */
private boolean soapFault(final SOAPMessage reply, final String[] faults) throws SOAPException {
    SOAPPart sp = reply.getSOAPPart();
    SOAPEnvelope envelope = sp.getEnvelope();
    SOAPBody body = envelope.getBody();
    if (!body.hasFault()) {
        return false;
    }
    SOAPFault fault = body.getFault();

    faults[0] = fault.getFaultCode();
    faults[1] = fault.getFaultString();
    faults[2] = fault.getFaultActor();

    // probably not neccessary with Microsoft;
    Detail detail = fault.getDetail();
    if (detail == null) {
        return true;
    }
    String detailMsg = ""; //$NON-NLS-1$
    Iterator it = detail.getDetailEntries();
    for (; it.hasNext();) {
        DetailEntry det = (DetailEntry) it.next();
        Iterator ita = det.getAllAttributes();
        for (boolean cont = false; ita.hasNext(); cont = true) {
            Name name = (Name) ita.next();
            if (cont) {
                detailMsg += "; "; //$NON-NLS-1$
            }
            detailMsg += name.getLocalName();
            detailMsg += " = "; //$NON-NLS-1$
            detailMsg += det.getAttributeValue(name);
        }
    }
    faults[3] = detailMsg;

    return true;
}