Example usage for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY

List of usage examples for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY

Introduction

In this page you can find the example usage for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY.

Prototype

String MESSAGE_OUTBOUND_PROPERTY

To view the source code for javax.xml.ws.handler MessageContext MESSAGE_OUTBOUND_PROPERTY.

Click Source Link

Document

Standard property: message direction, true for outbound messages, false for inbound.

Usage

From source file:cn.com.ttblog.ssmbootstrap_table.webservice.LicenseHandler.java

@SuppressWarnings("unchecked")
@Override//  w w  w  . j a v  a 2  s  .c o m
public boolean handleMessage(SOAPMessageContext context) {
    try {
        Boolean out = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
        logger.debug("LicenseHandler:{}", out);
        if (!out) {
            SOAPMessage message = context.getMessage();
            logger.debug("SOAPMessage:{}", ToStringBuilder.reflectionToString(message));
            SOAPEnvelope enve = message.getSOAPPart().getEnvelope();
            SOAPHeader header = enve.getHeader();
            SOAPBody body = enve.getBody();
            Node bn = body.getChildNodes().item(0);
            String partname = bn.getLocalName();
            if ("getUser".equals(partname)) {
                if (header == null) {
                    // ?
                    SOAPFault fault = body.addFault();
                    fault.setFaultString("??!");
                    throw new SOAPFaultException(fault);
                }
                Iterator<SOAPHeaderElement> iterator = header.extractAllHeaderElements();
                if (!iterator.hasNext()) {
                    // ?
                    SOAPFault fault = body.addFault();
                    fault.setFaultString("??!");
                    throw new SOAPFaultException(fault);
                }
                while (iterator.hasNext()) {
                    SOAPHeaderElement ele = iterator.next();
                    System.out.println(ele.getTextContent());
                }
            }
        }
    } catch (SOAPException e) {
        e.printStackTrace();
    }
    return true;
}

From source file:ebay.dts.client.LoggingHandler.java

private void log(SOAPMessageContext messageContext) {
    boolean request = ((Boolean) messageContext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)).booleanValue();

    SOAPMessage meg = messageContext.getMessage();

    ByteArrayOutputStream out = new ByteArrayOutputStream();

    try {//  w w  w.j  a v  a 2  s.  c o m
        meg.writeTo(out);
    } catch (Exception e) {
    }

    if (request) {
        logger.trace("SOAP Request message: " + new String(out.toByteArray()));
    } else {
        logger.trace("SOAP Response message: " + new String(out.toByteArray()));
    }

}

From source file:be.fedict.hsm.ws.impl.LoggingSOAPHandler.java

@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    LOG.debug("outbound message: " + outboundProperty);
    SOAPMessage soapMessage = context.getMessage();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {//from  w w w .jav  a  2 s  .  c  om
        soapMessage.writeTo(output);
    } catch (Exception e) {
        LOG.error("SOAP error: " + e.getMessage());
    }
    LOG.debug("SOAP message: " + output.toString());
    return true;
}

From source file:be.fedict.trust.xkms2.LoggingSoapHandler.java

public boolean handleFault(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    LOG.debug("outbound message: " + outboundProperty);
    SOAPMessage soapMessage = context.getMessage();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {//from   w w  w  . j av a2 s. c o m
        soapMessage.writeTo(output);
    } catch (Exception e) {
        LOG.error("SOAP error: " + e.getMessage());
    }
    LOG.debug("SOAP message: " + output.toString());
    return true;
}

From source file:be.e_contract.dssp.client.AttachmentsLogicalHandler.java

@Override
public boolean handleMessage(LogicalMessageContext context) {
    Boolean outbound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (!outbound) {
        this.inboundAttachments = (Map<String, DataHandler>) context
                .get(MessageContext.INBOUND_MESSAGE_ATTACHMENTS);
        LOG.debug("inbound attachments: " + this.inboundAttachments.keySet());
    }//  w  ww.  ja  v  a 2 s  . c om
    return true;
}

From source file:be.fedict.eid.dss.ws.LoggingSoapHandler.java

public boolean handleMessage(SOAPMessageContext context) {
    LOG.debug("handle message");
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    LOG.debug("outbound message: " + outboundProperty);
    SOAPMessage soapMessage = context.getMessage();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {/*  ww  w .  j a  v  a  2 s. co  m*/
        soapMessage.writeTo(output);
    } catch (Exception e) {
        LOG.error("SOAP error: " + e.getMessage());
    }
    LOG.debug("SOAP message: " + output.toString());
    return true;
}

From source file:be.fedict.eid.idp.sp.protocol.ws_federation.sts.LoggingSoapHandler.java

public boolean handleFault(SOAPMessageContext context) {
    if (false == LOG.isDebugEnabled()) {
        return true;
    }//  ww  w .  j a v  a2s .  com
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    LOG.debug("outbound message: " + outboundProperty);
    SOAPMessage soapMessage = context.getMessage();
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
        soapMessage.writeTo(output);
    } catch (Exception e) {
        LOG.error("SOAP error: " + e.getMessage());
    }
    LOG.debug("SOAP fault: " + output.toString());
    return true;
}

From source file:com.konakart.bl.modules.ordertotal.thomson.HeaderLoggingHandler.java

public boolean handleMessage(SOAPMessageContext smc) {
    Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    logSoapMsg(smc);/*from   w  w w  .  j a v a 2 s .  co  m*/
    return outboundProperty;
}

From source file:com.wavemaker.runtime.ws.jaxws.SOAPLoggingHandler.java

private void log(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    String messageText;//from  www.j av a2 s. c o  m
    if (outboundProperty.booleanValue()) {
        messageText = "Outbound SOAP message:\n";
    } else {
        messageText = "Inbound SOAP message:\n";
    }

    SOAPMessage message = context.getMessage();
    try {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        message.writeTo(baos);
        log.debug(messageText + baos.toString());
        baos.close();
    } catch (Exception e) {
        log.error(e);
    }
}

From source file:be.fedict.hsm.ws.impl.JAASSOAPHandler.java

@Override
public boolean handleMessage(SOAPMessageContext context) {
    Boolean outboundProperty = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (false == outboundProperty) {
        try {/*ww  w  . j  av  a 2 s. c  om*/
            login(context);
        } catch (Exception e) {
            this.securityAuditGeneratorBean.webServiceAuthenticationError();
            throw new ProtocolException("JAAS login error: " + e.getMessage(), e);
        }
    } else {
        try {
            logout(context);
        } catch (LoginException e) {
            this.securityAuditGeneratorBean.webServiceAuthenticationError();
            throw new ProtocolException("JAAS logout error: " + e.getMessage(), e);
        }
    }
    return true;
}