Example usage for javax.xml.ws.handler.soap SOAPMessageContext setMessage

List of usage examples for javax.xml.ws.handler.soap SOAPMessageContext setMessage

Introduction

In this page you can find the example usage for javax.xml.ws.handler.soap SOAPMessageContext setMessage.

Prototype

public void setMessage(SOAPMessage message);

Source Link

Document

Sets the SOAPMessage in this message context

Usage

From source file:eu.domibus.ebms3.receiver.FaultInHandler.java

private void processEbMSError(SOAPMessageContext context, EbMS3Exception ebMS3Exception) {

    // at this point an EbMS3Exception is available in any case
    SOAPMessage soapMessageWithEbMS3Error = null;
    try {/*  w  w w.ja v a  2 s  . c om*/
        soapMessageWithEbMS3Error = this.messageBuilder.buildSOAPFaultMessage(ebMS3Exception.getFaultInfo());
    } catch (EbMS3Exception e) {
        this.errorLogDao.create(new ErrorLogEntry(e));
    }
    context.setMessage(soapMessageWithEbMS3Error);

    Messaging messaging = this.extractMessaging(soapMessageWithEbMS3Error);

    FaultInHandler.LOG.debug("An error occurred while receiving a message with ebMS3 messageId: "
            + messaging.getSignalMessage().getMessageInfo().getMessageId()
            + ". Please check the database for more detailed information.", ebMS3Exception);

    this.errorLogDao.create(ErrorLogEntry.parse(messaging, MSHRole.RECEIVING));
}

From source file:de.drv.dsrv.spoc.web.webservice.jax.ExtraSchemaValidationHandler.java

@Override
public boolean handleMessage(final SOAPMessageContext context) {

    // Nur fuer den Eingang
    final Boolean isOutBound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (isOutBound) {
        return true;
    }/* www  . ja v  a  2 s.  c  om*/

    // Servlet-Context speichern
    final ServletContext servletContext = (ServletContext) context.get(MessageContext.SERVLET_CONTEXT);

    SOAPBody soapBody = getSoapBody(context);

    try {

        // Pruefe SOAP-Body
        if (soapBody == null) {
            try {
                // Erstelle neue SOAP-Message mit SOAP-Body
                final SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();
                soapBody = soapMessage.getSOAPBody();
                context.setMessage(soapMessage);
            } catch (final SOAPException e) {
                LOG.error("Exception beim Erstellen einer SOAP-Message.", e);
            }
            // Request ungueltig - z.B. ungueltiges XML
            throw new InvalidExtraRequestException(resourceBundle.getString(Messages.ERROR_REQUEST_NO_EXTRA));
        }

        // Hole Transport-Element
        final Node transportNode = getTransportElement(soapBody);
        if (transportNode == null) {
            // kein 'Transport'-Element, Request ungueltig
            throw new InvalidExtraRequestException(resourceBundle.getString(Messages.ERROR_REQUEST_NO_EXTRA));
        }

        // Validiere Request-XML gegen eXTra-Schema
        validateExtraRequest(transportNode, servletContext);

    } catch (final InvalidExtraRequestException e) {
        return handleException(soapBody, e.getMessage(), ExtraErrorReasonType.INVALID_REQUEST);
    } catch (final Exception e) {
        LOG.error("Unbekannter Fehler beim Request-Validierung.", e);
        return handleException(soapBody, resourceBundle.getString(Messages.ERROR_REQUEST_VALIDATION_UNKNOWN),
                ExtraErrorReasonType.UNSPECIFIED);
    }
    return true;
}