Example usage for javax.xml.soap SOAPConstants URI_NS_SOAP_1_2_ENVELOPE

List of usage examples for javax.xml.soap SOAPConstants URI_NS_SOAP_1_2_ENVELOPE

Introduction

In this page you can find the example usage for javax.xml.soap SOAPConstants URI_NS_SOAP_1_2_ENVELOPE.

Prototype

String URI_NS_SOAP_1_2_ENVELOPE

To view the source code for javax.xml.soap SOAPConstants URI_NS_SOAP_1_2_ENVELOPE.

Click Source Link

Document

The namespace identifier for the SOAP 1.2 envelope.

Usage

From source file:com.centurylink.mdw.hub.servlet.SoapServlet.java

/**
 * <p>/*from w  w  w . j a  va  2s  .co  m*/
 * Gives a hint as to which version of SOAP using the rudimentary check
 * below. If the hint fails, it'll try the other version anyway.
 * </p>
 * <ul>
 * <li>SOAP 1.1 : http://schemas.xmlsoap.org/soap/envelope/</li>
 * <li>SOAP 1.2 : http://www.w3.org/2003/05/soap-envelope</li>
 * </ul>
 * <p>
 * This is on a per-request basis and can't be static since we need to
 * support SOAP 1.1 and 1.2
 * </p>
 *
 * @param requestString
 * @param goodguess
 * @return SOAP version 1 or 2
 * @throws IOException
 * @throws SOAPException
 */
private String getSoapVersion(String requestString, boolean goodguess) {

    String guessedVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
    String otherVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
    if (requestString.contains(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE)) {
        guessedVersion = SOAPConstants.SOAP_1_2_PROTOCOL;
        otherVersion = SOAPConstants.SOAP_1_1_PROTOCOL;
    }
    return goodguess ? guessedVersion : otherVersion;

}

From source file:org.apache.axis2.datasource.jaxb.JAXBCustomBuilder.java

/**
 * @param namespace//  w ww  .  j  a  v a 2  s  . co m
 * @param localPart
 * @return true if this ns and local part is acceptable for unmarshalling
 */
private boolean shouldUnmarshal(String namespace, String localPart) {
    boolean isHighFidelity = HandlerUtils.isHighFidelity(jdsContext.getMessageContext());

    if (isHighFidelity) {
        if (log.isDebugEnabled()) {
            log.debug("JAXB payload streaming disabled because high fidelity messages are requested.");
        }
        return false;

    }

    // Don't unmarshall SOAPFaults or anything else in the SOAP 
    // namespace.
    // Don't unmarshall elements that are unqualified
    if (localPart == null || namespace == null || namespace.length() == 0
            || SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespace)
            || SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespace)) {
        return false;
    }

    // Don't unmarshal if this looks like encrypted data
    if (localPart.equals("EncryptedData")) {
        return false;
    }

    return true;

}

From source file:org.apache.axis2.jaxws.context.listener.ParserInputStreamCustomBuilder.java

/**
 * @param namespace/* w  ww .  j a  v a2s.  c  om*/
 * @param localPart
 * @return true if this ns and local part is acceptable for unmarshalling
 */
private boolean shouldUnmarshal(String namespace, String localPart) {

    /**
     * The stream preserves the original message, so I think
     * we want to do unmarshal even if high fidelity is specified.
             
    boolean isHighFidelity = HandlerUtils.isHighFidelity(msgContext);
            
    if (isHighFidelity) {
    return false;
    }
    */

    // Don't unmarshal SOAPFaults.
    // If there is no localPart, this also indicates a potential problem...so don't 
    // use the custom builder
    if (localPart == null
            || (localPart.equals("Fault") && (SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE.equals(namespace)
                    || SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE.equals(namespace)))) {
        return false;
    }

    /**
     * For JAXB custom building, we ignore security elements.
     * I don't think it matters for parsed entities since they preserve all the content
    if (localPart.equals("EncryptedData")) {
    return false;
    }
    */

    return true;

}

From source file:org.apache.axis2.jaxws.handler.HandlerChainProcessor.java

/**
 * Converts the Exception into an XML Fault Message that is stored on the MEPContext.
 * Note that if the forceConversion flag is true, this conversion will always occur.
 * If the checkMsg flag is true, this conversion only occurs if the Message is not already
 * a Fault (per 9,3,2.1 of the JAX-WS specification)
 * //from  ww w  .j a v a 2  s  .  co  m
 * @param mepCtx  MEPContext
 * @param e Exception
 * @param protocol Protocol
 * @param forceConversion  If true, the Exception is always converted to a Message
 */
public static void convertToFaultMessage(MEPContext mepCtx, Exception e, Protocol protocol, boolean checkMsg) {

    // need to check if message is already a fault message or not,
    // probably by way of a flag (isFault) in the MessageContext or Message
    if (log.isDebugEnabled()) {
        log.debug("start convertToFaultMessge with exception: " + e.getClass().getName());
        log.debug(" checkMsg is : " + checkMsg);
    }

    try {
        // According to the 9.3.2.1, The message is converted into a fault only if it is not already a Fault
        Message messageFromHandler = null;
        if (checkMsg) {
            messageFromHandler = mepCtx.getMessageContext().getMessage();
        }
        if (messageFromHandler != null && messageFromHandler.isFault()) {
            if (log.isDebugEnabled()) {
                log.debug("The Message is already a SOAPFault.  The exception is not converted into a Message");
            }
        } else if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
            if (log.isDebugEnabled()) {
                log.debug("Converting Exception into a Message");
            }
            String protocolNS = (protocol == Protocol.soap11) ? SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
                    : SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;

            // The following set of instructions is used to avoid 
            // some unimplemented methods in the Axis2 SAAJ implementation
            XMLFault xmlFault = MethodMarshallerUtils.createXMLFaultFromSystemException(e);
            javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
            SOAPMessage message = mf.createMessage();
            SOAPBody body = message.getSOAPBody();
            SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);

            MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
            Message msg = msgFactory.createFrom(message);
            mepCtx.setMessage(msg);

        } else {
            WebServiceException wse = ExceptionFactory
                    .makeWebServiceException(Messages.getMessage("cFaultMsgErr"));
            if (log.isDebugEnabled()) {
                log.debug("end convertToFaultMessge due to error ", wse);
            }
            throw wse;
        }

    } catch (Exception ex) {
        WebServiceException wse = ExceptionFactory.makeWebServiceException(ex);
        if (log.isDebugEnabled()) {
            log.debug("end convertToFaultMessge due to error ", wse);
        }
        throw wse;
    }

}

From source file:org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.java

/**
 * Create a system exception//from   w  w  w .  j ava2s.c  om
 *
 * @param message
 * @return
 */
public static ProtocolException createSystemException(XMLFault xmlFault, Message message) {
    ProtocolException e = null;
    Protocol protocol = message.getProtocol();
    String text = xmlFault.getReason().getText();

    if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
        // Throw a SOAPFaultException
        if (log.isDebugEnabled()) {
            log.debug("Constructing SOAPFaultException for " + text);
        }
        String protocolNS = (protocol == Protocol.soap11) ? SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
                : SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
        try {
            // The following set of instructions is used to avoid 
            // some unimplemented methods in the Axis2 SAAJ implementation
            javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
            SOAPBody body = mf.createMessage().getSOAPBody();
            SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);
            e = new SOAPFaultException(soapFault);
        } catch (Exception ex) {
            // Exception occurred during exception processing.
            // TODO Probably should do something better here
            if (log.isDebugEnabled()) {
                log.debug("Exception occurred during fault processing:", ex);
            }
            e = ExceptionFactory.makeProtocolException(text, null);
        }
    } else if (protocol == Protocol.rest) {
        if (log.isDebugEnabled()) {
            log.debug("Constructing ProtocolException for " + text);
        }
        // TODO Is there an explicit exception for REST
        e = ExceptionFactory.makeProtocolException(text, null);
    } else if (protocol == Protocol.unknown) {
        // REVIEW What should happen if there is no protocol
        if (log.isDebugEnabled()) {
            log.debug("Constructing ProtocolException for " + text);
        }
        e = ExceptionFactory.makeProtocolException(text, null);
    }
    return e;
}

From source file:org.apache.axis2.jaxws.message.impl.MessageImpl.java

public Object getValue(Object context, BlockFactory blockFactory) throws WebServiceException {
    try {//w ww  .jav  a2  s  . c  o m
        Object value = null;
        if (protocol == Protocol.rest) {
            // The implementation of rest stores the rest xml inside a dummy soap 1.1 envelope.
            // So use the get body block logic.
            Block block = xmlPart.getBodyBlock(context, blockFactory);
            if (block != null) {
                value = block.getBusinessObject(true);
            }

        } else {
            // Must be SOAP
            if (blockFactory instanceof SOAPEnvelopeBlockFactory) {
                value = getAsSOAPMessage();
            } else {
                // TODO: This doesn't seem right to me.
                // We should not have an intermediate StringBlock.
                // This is not performant. Scheu
                OMElement messageOM = getAsOMElement();
                String stringValue = messageOM.toString();
                String soapNS = (protocol == Protocol.soap11) ? SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE
                        : SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;
                QName soapEnvQname = new QName(soapNS, "Envelope");

                XMLStringBlockFactory stringFactory = (XMLStringBlockFactory) FactoryRegistry
                        .getFactory(XMLStringBlockFactory.class);
                Block stringBlock = stringFactory.createFrom(stringValue, null, soapEnvQname);
                Block block = blockFactory.createFrom(stringBlock, context);
                value = block.getBusinessObject(true);
            }
        }
        return value;
    } catch (Throwable e) {
        throw ExceptionFactory.makeWebServiceException(e);
    }
}