Package org.apache.axis2.engine

Examples of org.apache.axis2.engine.AxisEngine


    protected void handleFault(MessageContext msgContext, OutputStream out, AxisFault e)
            throws AxisFault {
        msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);

        AxisEngine engine = new AxisEngine(configContext);
        MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);

        engine.sendFault(faultContext);
    }
View Full Code Here


            StAXBuilder builder = new StAXSOAPModelBuilder(reader, null);
            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();

            msgCtx.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(confContext);

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgCtx);
            } else {
                engine.receive(msgCtx);
            }
        } catch (XMLStreamException e) {
            throw new AxisFault(e);
        } catch (FactoryConfigurationError e) {
            throw new AxisFault(e);
View Full Code Here

            return false;
        } else {
            msgContext.setDoingREST(true);
            msgContext.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(configurationContext);

            engine.receive(msgContext);

            return true;
        }
    }
View Full Code Here

                                + "character set encoding in the received SOAP message", faultCode);
            }

            msgContext.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgContext);
            } else {
                engine.receive(msgContext);
            }
        } catch (SOAPProcessingException e) {
            throw new AxisFault(e);
        } catch (AxisFault e) {
            throw e;
View Full Code Here

    public void run() {
        MessageContext msgContext = null;

        try {
            AxisEngine engine = new AxisEngine(configurationContext);
            AxisConfiguration axisConf = configurationContext.getAxisConfiguration();
            TransportOutDescription transportOut =
                    axisConf.getTransportOut(new QName(Constants.TRANSPORT_TCP));
            TransportInDescription transportIn =
                    axisConf.getTransportIn(new QName(Constants.TRANSPORT_TCP));

            if ((transportOut != null) && (transportIn != null)) {

                // create the Message Context and fill in the values
                msgContext = new MessageContext();
                msgContext.setIncomingTransportName(Constants.TRANSPORT_TCP);
                msgContext.setConfigurationContext(configurationContext);
                msgContext.setTransportIn(transportIn);
                msgContext.setTransportOut(transportOut);
                msgContext.setServerSide(true);

                OutputStream out = socket.getOutputStream();

                msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);

                // create the SOAP Envelope
                Reader in = new InputStreamReader(socket.getInputStream());
                XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
                StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();

                msgContext.setEnvelope(envelope);

                if (envelope.getBody().hasFault()) {
                    engine.receiveFault(msgContext);
                } else {
                    engine.receive(msgContext);
                }
            } else {
                throw new AxisFault(Messages.getMessage("unknownTransport",
                        Constants.TRANSPORT_TCP));
            }
        } catch (Throwable e) {
            try {
                AxisEngine engine = new AxisEngine(configurationContext);

                if (msgContext != null) {
                    msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());

                    MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);

                    engine.sendFault(faultContext);
                }
            } catch (Exception e1) {
                log.error(e);
            }
        } finally {
View Full Code Here

    /**
     * The main workhorse method.
     */
    public void run() {
        AxisEngine engine = new AxisEngine(configContext);
        MessageContext msgContext = null;

        // create and initialize a message context
        try {
            TransportInDescription transportIn =
                    configContext.getAxisConfiguration().getTransportIn(new QName(Constants.TRANSPORT_MAIL));
            TransportOutDescription transportOut =
                    configContext.getAxisConfiguration().getTransportOut(new QName(Constants.TRANSPORT_MAIL));

            if ((transportIn != null) && (transportOut != null)) {

                // create Message Context
                msgContext = new MessageContext();
                msgContext.setConfigurationContext(configContext);
                msgContext.setTransportIn(transportIn);
                msgContext.setTransportOut(transportOut);
                msgContext.setServerSide(true);
                msgContext.setProperty(MailSrvConstants.CONTENT_TYPE, mimeMessage.getContentType());
                msgContext.setProperty(MessageContext.CHARACTER_SET_ENCODING,
                        mimeMessage.getEncoding());

                String soapAction = getMailHeader(MailSrvConstants.HEADER_SOAP_ACTION);

                msgContext.setWSAAction(soapAction);
                msgContext.setSoapAction(soapAction);
                msgContext.setIncomingTransportName(Constants.TRANSPORT_MAIL);

                // TODO add the transport Headers to the Message Context
                // Create Mail EPR, EPR is constructed using the format, foo@bar/axis2/services/echo and is constructed
                // using the <to-email-address>/<email-subject>
                InternetAddress[] recepainets = (InternetAddress[]) mimeMessage.getAllRecipients();

                if ((recepainets != null) && (recepainets.length > 0)) {
                } else {
                    throw new AxisFault(Messages.getMessage("noRecep4Email"));
                }

                // try to assume the reply to value
                InternetAddress[] replyToAs = (InternetAddress[]) mimeMessage.getAllRecipients();

                if ((replyToAs != null) && (replyToAs.length > 0)) {
                    String replyTo = replyToAs[0].getAddress();

                    if (replyTo != null) {
                        msgContext.setReplyTo(new EndpointReference(replyTo));
                    }
                }

                // Create the SOAP Message
                // TODO This can we written better way, to use the streams better
                String message = mimeMessage.getContent().toString();
                ByteArrayInputStream bais =
                        new ByteArrayInputStream(message.getBytes());
                XMLStreamReader reader =
                        XMLInputFactory.newInstance().createXMLStreamReader(bais);
                String soapNamespaceURI = "";

                if (mimeMessage.getContentType().indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE)
                        > -1) {
                    soapNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                } else if (mimeMessage.getContentType().indexOf(
                        SOAP11Constants.SOAP_11_CONTENT_TYPE) > -1) {
                    soapNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
                }

                StAXBuilder builder = new StAXSOAPModelBuilder(reader, soapNamespaceURI);
                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();

                msgContext.setEnvelope(envelope);

                if (envelope.getBody().hasFault()) {
                    engine.receiveFault(msgContext);
                } else {
                    engine.receive(msgContext);
                }
            } else {
                throw new AxisFault(Messages.getMessage("unknownTransport",
                        Constants.TRANSPORT_MAIL));
            }
        } catch (Exception e) {
            try {
                if (msgContext != null) {
                    MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);

                    engine.sendFault(faultContext);
                } else {
                    log.error(e);
                }
            } catch (AxisFault e1) {
                log.error(e);
View Full Code Here

                                + "character set encoding in the received SOAP message", faultCode);
            }

            msgContext.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgContext);
            } else {
                engine.receive(msgContext);
            }
        } catch (SOAPProcessingException e) {
            throw new AxisFault(e);
        } catch (AxisFault e) {
View Full Code Here

            if (!(e instanceof java.net.SocketException)) {
                log.debug(e.getMessage(), e);
            }

            try {
                AxisEngine engine = new AxisEngine(configurationContext);

                if (msgContext != null) {
                    msgContext.setProperty(MessageContext.TRANSPORT_OUT, baos);

                    MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);

                    response.setStatusLine(request.getRequestLine().getHttpVersion(), 500,
                            "Internal server error");
                    engine.sendFault(faultContext);
                    byte[] buf = baos.toByteArray();
                    response.setBody(new ByteArrayInputStream(buf));
                    setResponseHeaders(conn, request, response, buf.length, msgContext);
                    conn.writeResponse(response);
                }
View Full Code Here

    public void run() {
        MessageContext msgContext = null;

        try {
            AxisEngine engine = new AxisEngine(configurationContext);
            AxisConfiguration axisConf = configurationContext.getAxisConfiguration();
            TransportOutDescription transportOut =
                    axisConf.getTransportOut(new QName(Constants.TRANSPORT_TCP));
            TransportInDescription transportIn =
                    axisConf.getTransportIn(new QName(Constants.TRANSPORT_TCP));

            if ((transportOut != null) && (transportIn != null)) {

                // create the Message Context and fill in the values
                msgContext = new MessageContext();
                msgContext.setConfigurationContext(configurationContext);
                msgContext.setTransportIn(transportIn);
                msgContext.setTransportOut(transportOut);
                msgContext.setServerSide(true);

                OutputStream out = socket.getOutputStream();

                msgContext.setProperty(MessageContext.TRANSPORT_OUT, out);

                // create the SOAP Envelope
                Reader in = new InputStreamReader(socket.getInputStream());
                XMLStreamReader xmlreader = XMLInputFactory.newInstance().createXMLStreamReader(in);
                StAXBuilder builder = new StAXSOAPModelBuilder(xmlreader, null);
                SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();

                msgContext.setEnvelope(envelope);

                if (envelope.getBody().hasFault()) {
                    engine.receiveFault(msgContext);
                } else {
                    engine.receive(msgContext);
                }
            } else {
                throw new AxisFault(Messages.getMessage("unknownTransport",
                        Constants.TRANSPORT_TCP));
            }
        } catch (Throwable e) {
            try {
                AxisEngine engine = new AxisEngine(configurationContext);

                if (msgContext != null) {
                    msgContext.setProperty(MessageContext.TRANSPORT_OUT, socket.getOutputStream());

                    MessageContext faultContext = engine.createFaultMessageContext(msgContext, e);

                    engine.sendFault(faultContext);
                }
            } catch (Exception e1) {
                log.error(e);
            }
        } finally {
View Full Code Here

                                + "character set encoding in the received SOAP message", faultCode);
            }

            msgContext.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(msgContext.getConfigurationContext());

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgContext);
            } else {
                engine.receive(msgContext);
            }
        } catch (SOAPProcessingException e) {
            throw new AxisFault(e);
        } catch (AxisFault e) {
View Full Code Here

TOP

Related Classes of org.apache.axis2.engine.AxisEngine

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.