Package org.apache.ws.commons.soap.impl.llom.soap11

Examples of org.apache.ws.commons.soap.impl.llom.soap11.SOAP11Factory


                        (String) contentType,true);
                envelope = (SOAPEnvelope) builder.getDocumentElement();
            } else if (msgContext.isDoingREST()) {
                XMLStreamReader xmlreader =
                        StAXUtils.createXMLStreamReader(inStream, charSetEnc);
                SOAPFactory soapFactory = new SOAP11Factory();

                builder = new StAXOMBuilder(xmlreader);
                builder.setOMBuilderFactory(soapFactory);
                envelope = soapFactory.getDefaultEnvelope();
                envelope.getBody().addChild(builder.getDocumentElement());
               
                // We now have the message inside an envolope. However, this is
                // only an OM; We need to build a SOAP model from it.
View Full Code Here


                }
            }
        }

        if (builder == null) {
            SOAPFactory soapFactory = new SOAP11Factory();
            try {
                XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader
                    (in, MessageContext.DEFAULT_CHAR_SET_ENCODING);

                // Set the encoding scheme in the message context
                msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                                       MessageContext.DEFAULT_CHAR_SET_ENCODING);
                builder = new StAXOMBuilder(xmlreader);
                builder.setOMBuilderFactory(soapFactory);

                String ns = builder.getDocumentElement().getNamespace().getNamespaceURI();
                if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = getEnvelope(in, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = getEnvelope(in, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
                } else {
                    // this is POX ... mark MC as REST
                    msgContext.setDoingREST(true);
                    envelope = soapFactory.getDefaultEnvelope();
                    envelope.getBody().addChild(builder.getDocumentElement());
                }
            } catch (Exception e) {
                log.debug("Non SOAP/XML JMS message received");

                Parameter operationParam = msgContext.getAxisService().
                    getParameter(JMSConstants.OPERATION_PARAM);
                QName operationQName = (operationParam != null ?
                    getQName(operationParam.getValue()) : JMSConstants.DEFAULT_OPERATION);

                AxisOperation operation = msgContext.getAxisService().getOperation(operationQName);
                if (operation != null) {
                    msgContext.setAxisOperation(operation);
                } else {
                    handleException("Cannot find operation : " + operationQName + " on the service "
                        + msgContext.getAxisService());
                }


                Parameter wrapperParam = msgContext.getAxisService().
                    getParameter(JMSConstants.WRAPPER_PARAM);
                QName wrapperQName = (wrapperParam != null ?
                    getQName(wrapperParam.getValue()) : JMSConstants.DEFAULT_WRAPPER);

                OMElement wrapper = soapFactory.createOMElement(wrapperQName, null);

                try {
                    if (message instanceof TextMessage) {
                        OMTextImpl textData = (OMTextImpl) soapFactory.createOMText(
                            ((TextMessage) message).getText());
                        wrapper.addChild(textData);
                    } else if (message instanceof BytesMessage) {
                        BytesMessage bm = (BytesMessage) message;
                        byte[] msgBytes = new byte[(int) bm.getBodyLength()];
                        bm.reset();
                        bm.readBytes(msgBytes);
                        DataHandler dataHandler = new DataHandler(
                            new ByteArrayDataSource(msgBytes));
                        OMText textData = soapFactory.createOMText(dataHandler, true);
                        wrapper.addChild(textData);
                        msgContext.setDoingMTOM(true);
                    } else {
                        handleException("Unsupported JMS Message format : " + message.getJMSType());
                    }
                    envelope = soapFactory.getDefaultEnvelope();
                    envelope.getBody().addChild(wrapper);

                } catch (JMSException j) {
                    handleException("Error wrapping JMS message into a SOAP envelope ", j);
                }
View Full Code Here

    SOAPEnvelope dummyEnvelope = null;
    if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
      factory = new SOAP12Factory();
      dummyEnvelope = factory.getDefaultEnvelope();
    } else {
      factory = new SOAP11Factory();
      dummyEnvelope = factory.getDefaultEnvelope();
    }

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
View Full Code Here

      if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
        factory = new SOAP12Factory();
        dummyEnvelope = factory.getDefaultEnvelope();
      } else {
        factory = new SOAP11Factory();
        dummyEnvelope = factory.getDefaultEnvelope();
      }

      String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
View Full Code Here

      soapNamespaceURI = getSOAPNamespaceURI(storageManager, internalSequenceID);
    if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapNamespaceURI)) {
      factory = new SOAP12Factory();
      dummyEnvelope = factory.getDefaultEnvelope();
    } else {
      factory = new SOAP11Factory();
      dummyEnvelope = factory.getDefaultEnvelope();
    }

    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(rmSpecVersion);
    TerminateSequence terminateSequence = new TerminateSequence(rmNamespaceValue);
View Full Code Here

                    responseMsgCtx.setTo(null);

                    if (!outMsgCtx.isDoingREST() && !outMsgCtx.isSOAP11()) {
                        responseMsgCtx.setEnvelope(new SOAP12Factory().getDefaultEnvelope());
                    } else {
                        responseMsgCtx.setEnvelope(new SOAP11Factory().getDefaultEnvelope());
                    }
                    responseMsgCtx.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
                    responseMsgCtx.setProperty(NhttpConstants.SC_ACCEPTED, Boolean.TRUE);
                    mr.receive(responseMsgCtx);
View Full Code Here

                in,
                contentType);
            } catch (OMException e) {
                // handle non SOAP and POX/REST payloads (probably text/html)
                log.error("Unexpected response received", e);
                SOAPFactory factory = new SOAP11Factory();
                envelope = factory.getDefaultFaultEnvelope();
                SOAPFaultDetail detail = factory.createSOAPFaultDetail();
                detail.setText("Unexpected response received : " + e.getMessage());
                envelope.getBody().getFault().setDetail(detail);
                SOAPFaultReason reason = factory.createSOAPFaultReason();
                reason.setText(this.response.getStatusLine().getReasonPhrase());
                envelope.getBody().getFault().setReason(reason);
                SOAPFaultCode code = factory.createSOAPFaultCode();
                code.setText(Integer.toString(this.response.getStatusLine().getStatusCode()));
                envelope.getBody().getFault().setCode(code);
            }
            responseMsgCtx.setServerSide(true);
            responseMsgCtx.setEnvelope(envelope);
View Full Code Here


        // handle SOAP when content type is missing, or any other POX, binary or text payload
        if (builder == null) {

            SOAPFactory soapFactory = new SOAP11Factory();
            try {
                builder = new StAXOMBuilder(StAXUtils.createXMLStreamReader(in, charSetEnc));
                builder.setOMBuilderFactory(OMAbstractFactory.getOMFactory());
                String ns = builder.getDocumentElement().getNamespace().getNamespaceURI();

                if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = BaseUtils.getEnvelope(in, SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);

                } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)) {
                    envelope = BaseUtils.getEnvelope(in, SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);

                } else {
                    // this is POX ... mark message as REST
                    msgContext.setDoingREST(true);
                    envelope = soapFactory.getDefaultEnvelope();
                    envelope.getBody().addChild(builder.getDocumentElement());
                }

            } catch (Exception e) {
                envelope = handleLegacyMessage(msgContext, message);
View Full Code Here

     * @param message the legacy message
     * @return the SOAP envelope
     */
    private SOAPEnvelope handleLegacyMessage(MessageContext msgContext, Object message) {

        SOAPFactory soapFactory = new SOAP11Factory();
        SOAPEnvelope envelope = null;

        if (log.isDebugEnabled()) {
            log.debug("Non SOAP/XML message received");
        }

        // pick the name of the element that will act as the wrapper element for the
        // non-xml payload. If service doesn't define one, default
        Parameter wrapperParam = msgContext.getAxisService().
            getParameter(BaseConstants.WRAPPER_PARAM);

        QName wrapperQName = null;
        OMElement wrapper = null;
        if (wrapperParam != null) {
            wrapperQName = BaseUtils.getQNameFromString(wrapperParam.getValue());
        }

        String textPayload = getMessageTextPayload(message);
        if (textPayload != null) {
            OMTextImpl textData = (OMTextImpl) soapFactory.createOMText(textPayload);

            if (wrapperQName == null) {
                wrapperQName = BaseConstants.DEFAULT_TEXT_WRAPPER;
            }
            wrapper = soapFactory.createOMElement(wrapperQName, null);
            wrapper.addChild(textData);

        } else {
            byte[] msgBytes = getMessageBinaryPayload(message);
            if (msgBytes != null) {
                DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(msgBytes));
                OMText textData = soapFactory.createOMText(dataHandler, true);
                if (wrapperQName == null) {
                    wrapperQName = BaseConstants.DEFAULT_BINARY_WRAPPER;
                }
                wrapper = soapFactory.createOMElement(wrapperQName, null);
                wrapper.addChild(textData);
                msgContext.setDoingMTOM(true);
               
            } else {
                handleException("Unable to read payload from message of type : "
                    + message.getClass().getName());
            }
        }

        envelope = soapFactory.getDefaultEnvelope();
        envelope.getBody().addChild(wrapper);

        return envelope;
    }
View Full Code Here

        if (documentElement instanceof SOAPEnvelope) {
            envelope = (SOAPEnvelope) documentElement;
        } else {
            // If it is not a SOAPEnvelope we wrap that with a fake
            // SOAPEnvelope.
            SOAPFactory soapFactory = new SOAP11Factory();
            envelope = soapFactory.getDefaultEnvelope();
            envelope.getBody().addChild(documentElement);
        }
        return envelope;
    }
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.soap.impl.llom.soap11.SOAP11Factory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.