Example usage for javax.xml.ws.soap SOAPFaultException getCause

List of usage examples for javax.xml.ws.soap SOAPFaultException getCause

Introduction

In this page you can find the example usage for javax.xml.ws.soap SOAPFaultException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:eu.domibus.ebms3.sender.MessageSender.java

/**
 * This method gets called from {@link MessageSender#sendAllUserMessages()}
 * for all unsent messages/* ww  w .j a v  a2s.co  m*/
 *
 * @param messageId id of the message to send
 */
@Transactional(Transactional.TxType.REQUIRES_NEW)
private void sendUserMessage(final String messageId) {
    boolean reliabilityCheckSuccessful = false;
    EbmsErrorChecker.CheckResult errorCheckResult = null;

    LegConfiguration legConfiguration = null;
    String pModeKey = null;
    if (MessageSender.LOG.isTraceEnabled()) {
        MessageSender.LOG
                .trace("Transaction active: " + TransactionSynchronizationManager.getCurrentTransactionName());
    }
    final UserMessage userMessage = this.messagingDao.findUserMessageByMessageId(messageId);
    try {
        pModeKey = this.pModeProvider.findPModeKeyForUserMesssage(userMessage);
        legConfiguration = this.pModeProvider.getLegConfiguration(pModeKey);

        MessageSender.LOG.debug("PMode found : " + pModeKey);
        SOAPMessage soapMessage = this.messageBuilder.buildSOAPMessage(userMessage, legConfiguration);
        SOAPMessage response = this.mshDispatcher.dispatch(soapMessage, pModeKey);
        errorCheckResult = this.ebmsErrorChecker.check(soapMessage, response, pModeKey);
        if (EbmsErrorChecker.CheckResult.ERROR.equals(errorCheckResult)) {
            throw new EbMS3Exception(EbMS3Exception.EbMS3ErrorCode.EBMS_0004,
                    "Problem occured during marshalling", messageId, null, MSHRole.SENDING);
        }
        reliabilityCheckSuccessful = this.reliabilityChecker.check(soapMessage, response, pModeKey);
    } catch (SOAPFaultException f) {
        if (f.getCause() instanceof Fault && f.getCause().getCause() instanceof EbMS3Exception) {
            this.handleEbms3Exception((EbMS3Exception) f.getCause().getCause(), messageId, legConfiguration);
        }

    } catch (EbMS3Exception e) {
        this.handleEbms3Exception(e, messageId, legConfiguration);
    } finally {
        if (reliabilityCheckSuccessful) {

            switch (errorCheckResult) {
            case OK:
                this.messageLogDao.setMessageAsSent(messageId);
                break;
            case WARNING:
                this.messageLogDao.setMessageAsSentWithWarnings(messageId);
                break;
            case ERROR:
                assert false;
                break;
            default:
                assert false;
            }
        } else {
            this.updateRetryLogging(messageId, legConfiguration);
        }

    }
}

From source file:org.olat.modules.vitero.manager.ViteroManager.java

private final ErrorCode handleAxisFault(final SOAPFaultException f) throws VmsNotAvailableException {
    if (f.getFault() != null) {
        String errorCode = extractErrorCode(f.getFault());
        if (StringHelper.isLong(errorCode)) {
            int code = Integer.parseInt(errorCode);
            return ErrorCode.find(code);
        }/*from   w  w w . j  ava2s .c o m*/
        return ErrorCode.unkown;
    } else if (f.getCause() instanceof ConnectTimeoutException) {
        throw new VmsNotAvailableException(f);
    }
    return ErrorCode.unkown;
}

From source file:org.openehealth.ipf.platform.camel.ihe.ws.AbstractWsProducer.java

@Override
public void process(Exchange exchange) throws Exception {
    // prepare/*  www  .  j  a  v  a 2  s.c  o  m*/
    InType body = exchange.getIn().getMandatoryBody(requestClass);
    Object client = getClient();
    configureClient(client);
    BindingProvider bindingProvider = (BindingProvider) client;
    WrappedMessageContext requestContext = (WrappedMessageContext) bindingProvider.getRequestContext();
    cleanRequestContext(requestContext);

    enrichRequestContext(exchange, requestContext);
    processUserDefinedOutgoingHeaders(requestContext, exchange.getIn(), true);

    // set request encoding based on Camel exchange property
    String requestEncoding = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
    if (requestEncoding != null) {
        requestContext.put(org.apache.cxf.message.Message.ENCODING, requestEncoding);
    }

    // get and analyse WS-Addressing asynchrony configuration
    String replyToUri = getWsTransactionConfiguration().isAllowAsynchrony()
            ? exchange.getIn().getHeader(AbstractWsEndpoint.WSA_REPLYTO_HEADER_NAME, String.class)
            : null;
    if ((replyToUri != null) && replyToUri.trim().isEmpty()) {
        replyToUri = null;
    }

    // for asynchronous interaction: configure WSA headers and store correlation data
    if ((replyToUri != null)
            || Boolean.TRUE.equals(requestContext.get(AsynchronyCorrelator.FORCE_CORRELATION))) {
        String messageId = "urn:uuid:" + UUID.randomUUID().toString();
        configureWSAHeaders(messageId, replyToUri, requestContext);

        AbstractWsEndpoint endpoint = (AbstractWsEndpoint) getEndpoint();
        AsynchronyCorrelator correlator = endpoint.getCorrelator();
        correlator.storeServiceEndpointUri(messageId, endpoint.getEndpointUri());

        String correlationKey = exchange.getIn().getHeader(AbstractWsEndpoint.CORRELATION_KEY_HEADER_NAME,
                String.class);
        if (correlationKey != null) {
            correlator.storeCorrelationKey(messageId, correlationKey);
        }

        String[] alternativeKeys = getAlternativeRequestKeys(exchange);
        if (alternativeKeys != null) {
            correlator.storeAlternativeKeys(messageId, alternativeKeys);
        }
    }

    // invoke
    exchange.setPattern((replyToUri == null) ? ExchangePattern.InOut : ExchangePattern.InOnly);
    OutType result = null;
    try {
        // normalize response type when called via reflection or similar non-type-safe mechanisms
        result = responseClass.cast(callService(client, body));
    } catch (SOAPFaultException fault) {
        // handle http://www.w3.org/TR/2006/NOTE-soap11-ror-httpbinding-20060321/
        // see also: https://issues.apache.org/jira/browse/CXF-3768
        if ((replyToUri == null) || (fault.getCause() == null)
                || !fault.getCause().getClass().getName().equals("com.ctc.wstx.exc.WstxEOFException")) {
            throw fault;
        }
    }

    // for synchronous interaction (replyToUri == null): handle response.
    // (async responses are handled in the service instance derived from 
    // org.openehealth.ipf.platform.camel.ihe.ws.AbstractAsyncResponseWebService)
    if (replyToUri == null) {
        Message responseMessage = Exchanges.resultMessage(exchange);
        responseMessage.getHeaders().putAll(exchange.getIn().getHeaders());
        WrappedMessageContext responseContext = (WrappedMessageContext) bindingProvider.getResponseContext();
        processIncomingHeaders(responseContext, responseMessage);
        enrichResponseMessage(responseMessage, responseContext);

        // set Camel exchange property based on response encoding
        exchange.setProperty(Exchange.CHARSET_NAME,
                responseContext.get(org.apache.cxf.message.Message.ENCODING));
        responseMessage.setBody(result, responseClass);
    }
}