Package org.apache.axis2.engine.Handler

Examples of org.apache.axis2.engine.Handler.InvocationResponse


  public InvocationResponse processSequenceHeader(RMMsgContext rmMsgCtx, Transaction transaction) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: SequenceProcessor::processSequenceHeader");
   
    InvocationResponse result = InvocationResponse.CONTINUE;
    Sequence sequence = rmMsgCtx.getSequence();
    if(sequence != null) {
      // This is a reliable message, so hand it on to the main routine
      result = processReliableMessage(rmMsgCtx, transaction);
    } else {
View Full Code Here


 
  public InvocationResponse processReliableMessage(RMMsgContext rmMsgCtx, Transaction transaction) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: SequenceProcessor::processReliableMessage");

    InvocationResponse result = InvocationResponse.CONTINUE;
   
    if (rmMsgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE) != null
        && rmMsgCtx.getProperty(Sandesha2Constants.APPLICATION_PROCESSING_DONE).equals("true")) {
      return result;
    }
View Full Code Here

        // Set the initial execution chain in the MessageContext to a *copy* of what
        // we got above.  This allows individual message processing to change the chain without
        // affecting later messages.
        msgContext.setExecutionChain((ArrayList) preCalculatedPhases.clone());
        msgContext.setFLOW(MessageContext.IN_FLOW);
        InvocationResponse pi = invoke(msgContext);

        if (pi.equals(InvocationResponse.CONTINUE)) {
            if (msgContext.isServerSide()) {

                // invoke the Message Receivers
                checkMustUnderstand(msgContext);

View Full Code Here

    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
        if (msgContext.getCurrentHandlerIndex() == -1) {
            msgContext.setCurrentHandlerIndex(0);
        }

        InvocationResponse pi = InvocationResponse.CONTINUE;

        while (msgContext.getCurrentHandlerIndex() < msgContext.getExecutionChain().size()) {
            Handler currentHandler = (Handler) msgContext.getExecutionChain().
                    get(msgContext.getCurrentHandlerIndex());
            pi = currentHandler.invoke(msgContext);

            if (pi.equals(InvocationResponse.SUSPEND) ||
                    pi.equals(InvocationResponse.ABORT)) {
                break;
            }
            msgContext.setCurrentHandlerIndex(msgContext.getCurrentHandlerIndex() + 1);
        }
View Full Code Here

     *         whether or not the message processing will ever succeed.
     * @throws AxisFault
     */
    public InvocationResponse resumeReceive(MessageContext msgContext) throws AxisFault {
        //invoke the phases
        InvocationResponse pi = invoke(msgContext);

        if (pi.equals(InvocationResponse.CONTINUE)) {
            //invoking the MR
            if (msgContext.isServerSide()) {
                // invoke the Message Receivers
                checkMustUnderstand(msgContext);
                MessageReceiver receiver = msgContext.getAxisOperation().getMessageReceiver();
View Full Code Here

     * @return An InvocationResponse allowing the invoker to perhaps determine
     *         whether or not the message processing will ever succeed.
     */
    public InvocationResponse resumeSend(MessageContext msgContext) throws AxisFault {
        //invoke the phases
        InvocationResponse pi = invoke(msgContext);
        //Invoking Tarnsport Sender
        if (pi.equals(InvocationResponse.CONTINUE)) {
            // write the Message to the Wire
            TransportOutDescription transportOut = msgContext.getTransportOut();
            TransportSender sender = transportOut.getSender();
            sender.invoke(msgContext);
        }
View Full Code Here

        // Set the initial execution chain in the MessageContext to a *copy* of what
        // we got above.  This allows individual message processing to change the chain without
        // affecting later messages.
        msgContext.setExecutionChain((ArrayList) preCalculatedPhases.clone());
        msgContext.setFLOW(MessageContext.IN_FAULT_FLOW);
        InvocationResponse pi = invoke(msgContext);

        if (pi.equals(InvocationResponse.CONTINUE)) {
            if (msgContext.isServerSide()) {

                // invoke the Message Receivers
                checkMustUnderstand(msgContext);

View Full Code Here

        outPhases.addAll((ArrayList) executionChain.clone());
        outPhases.addAll((ArrayList) msgContext.getConfigurationContext()
                .getAxisConfiguration().getGlobalOutPhases().clone());
        msgContext.setExecutionChain(outPhases);
        msgContext.setFLOW(MessageContext.OUT_FLOW);
        InvocationResponse pi = invoke(msgContext);

        if (pi.equals(InvocationResponse.CONTINUE)) {

            // write the Message to the Wire
            TransportOutDescription transportOut = msgContext.getTransportOut();
            if (transportOut == null) {
                throw new AxisFault("Transport out has not been set");
View Full Code Here

     * @throws AxisFault
     */
    public void sendFault(MessageContext msgContext) throws AxisFault {
        OperationContext opContext = msgContext.getOperationContext();

        InvocationResponse pi = InvocationResponse.CONTINUE;

        // find and execute the Fault Out Flow Handlers
        if (opContext != null) {
            AxisOperation axisOperation = opContext.getAxisOperation();
            ArrayList faultExecutionChain = axisOperation.getPhasesOutFaultFlow();

            //adding both operation specific and global out fault flows.

            ArrayList outFaultPhases = new ArrayList();
            outFaultPhases.addAll((ArrayList) faultExecutionChain.clone());
            msgContext.setExecutionChain((ArrayList) outFaultPhases.clone());
            msgContext.setFLOW(MessageContext.OUT_FAULT_FLOW);
            pi = invoke(msgContext);
        }

        if (pi.equals(InvocationResponse.CONTINUE)) {
            msgContext.setExecutionChain(
                    (ArrayList) msgContext.getConfigurationContext()
                            .getAxisConfiguration().getOutFaultFlow().clone());
            msgContext.setFLOW(MessageContext.OUT_FAULT_FLOW);
            invoke(msgContext);
View Full Code Here

                (servicePath.startsWith("/") ? servicePath : "/" + servicePath) + "/";

        String uri = request.getRequestURI();
        String method = request.getMethod();
        String soapAction = HttpUtils.getSoapAction(request);
        InvocationResponse pi;

        if (method.equals(HTTPConstants.HEADER_GET)) {
            if (uri.equals("/favicon.ico")) {
                response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
                response.addHeader(new BasicHeader("Location", "http://ws.apache.org/favicon.ico"));
                return;
            }
            if (!uri.startsWith(contextPath)) {
                response.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
                response.addHeader(new BasicHeader("Location", contextPath));
                return;
            }
            if (uri.endsWith("axis2/services/")) {
                String s = HTTPTransportReceiver.getServicesHTML(configurationContext);
                response.setStatus(HttpStatus.SC_OK);
                response.setContentType("text/html");
                OutputStream out = response.getOutputStream();
                out.write(EncodingUtils.getBytes(s, HTTP.ISO_8859_1));
                return;
            }
            if (uri.indexOf("?") < 0) {
                if (!uri.endsWith(contextPath)) {
                    if (uri.endsWith(".xsd") || uri.endsWith(".wsdl")) {
                        HashMap services = configurationContext.getAxisConfiguration().getServices();
                        String file = uri.substring(uri.lastIndexOf("/") + 1,
                                uri.length());
                        if ((services != null) && !services.isEmpty()) {
                            Iterator i = services.values().iterator();
                            while (i.hasNext()) {
                                AxisService service = (AxisService) i.next();
                                InputStream stream = service.getClassLoader().getResourceAsStream("META-INF/" + file);
                                if (stream != null) {
                                    OutputStream out = response.getOutputStream();
                                    response.setContentType("text/xml");
                                    ListingAgent.copy(stream, out);
                                    out.flush();
                                    out.close();
                                    return;
                                }
                            }
                        }
                    } else {
                        String serviceName = uri.replaceAll(contextPath, "");
                        if (serviceName.indexOf("/") < 0) {
                            String s = HTTPTransportReceiver
                                    .printServiceHTML(serviceName, configurationContext);
                            response.setStatus(HttpStatus.SC_OK);
                            response.setContentType("text/html");
                            OutputStream out = response.getOutputStream();
                            out.write(EncodingUtils.getBytes(s, HTTP.ISO_8859_1));
                            return;
                        }
                    }
                }
            }
            if (uri.endsWith("?wsdl2")) {
                String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 6);
                HashMap services = configurationContext.getAxisConfiguration().getServices();
                AxisService service = (AxisService) services.get(serviceName);
                if (service != null) {
                    response.setStatus(HttpStatus.SC_OK);
                    response.setContentType("text/xml");
                    service.printWSDL2(response.getOutputStream(), getHost(request));
                    return;
                }
            }
            if (uri.endsWith("?wsdl")) {
                String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 5);
                HashMap services = configurationContext.getAxisConfiguration().getServices();
                AxisService service = (AxisService) services.get(serviceName);
                if (service != null) {
                    response.setStatus(HttpStatus.SC_OK);
                    response.setContentType("text/xml");
                    service.printWSDL(response.getOutputStream(), getHost(request));
                    return;
                }
            }
            if (uri.endsWith("?xsd")) {
                String serviceName = uri.substring(uri.lastIndexOf("/") + 1, uri.length() - 4);
                HashMap services = configurationContext.getAxisConfiguration().getServices();
                AxisService service = (AxisService) services.get(serviceName);
                if (service != null) {
                    response.setStatus(HttpStatus.SC_OK);
                    response.setContentType("text/xml");
                    service.printSchema(response.getOutputStream());
                    return;
                }
            }
            //cater for named xsds - check for the xsd name
            if (uri.indexOf("?xsd=") > 0) {
                String serviceName =
                        uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?xsd="));
                String schemaName = uri.substring(uri.lastIndexOf("=") + 1);

                HashMap services = configurationContext.getAxisConfiguration().getServices();
                AxisService service = (AxisService) services.get(serviceName);
                if (service != null) {
                    //run the population logic just to be sure
                    service.populateSchemaMappings();
                    //write out the correct schema
                    Map schemaTable = service.getSchemaMappingTable();
                    XmlSchema schema = (XmlSchema) schemaTable.get(schemaName);
                    if (schema == null) {
                        int dotIndex = schemaName.indexOf('.');
                        if (dotIndex > 0) {
                            String schemaKey = schemaName.substring(0,dotIndex);
                            schema = (XmlSchema) schemaTable.get(schemaKey);
                        }
                    }
                    //schema found - write it to the stream
                    if (schema != null) {
                        response.setStatus(HttpStatus.SC_OK);
                        response.setContentType("text/xml");
                        schema.write(response.getOutputStream());
                        return;
                    } else {
                        InputStream instream = service.getClassLoader()
                            .getResourceAsStream(DeploymentConstants.META_INF + "/" + schemaName);
                       
                        if (instream != null) {
                            response.setStatus(HttpStatus.SC_OK);
                            response.setContentType("text/xml");
                            OutputStream outstream = response.getOutputStream();
                            boolean checkLength = true;
                            int length = Integer.MAX_VALUE;
                            int nextValue = instream.read();
                            if (checkLength) length--;
                            while (-1 != nextValue && length >= 0) {
                                outstream.write(nextValue);
                                nextValue = instream.read();
                                if (checkLength) length--;
                            }
                            outstream.flush();
                            return;
                        } else {
                            // no schema available by that name  - send 404
                            response.sendError(HttpStatus.SC_NOT_FOUND, "Schema Not Found!");
                            return;
                        }
                    }
                }
            }
            if (uri.indexOf("?wsdl2=") > 0) {
                String serviceName =
                        uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl2="));
                if (processInternalWSDL(uri, configurationContext, serviceName, response)) return;
            }
            if (uri.indexOf("?wsdl=") > 0) {
                String serviceName =
                        uri.substring(uri.lastIndexOf("/") + 1, uri.lastIndexOf("?wsdl="));
                if (processInternalWSDL(uri, configurationContext, serviceName, response)) return;
            }

            String contentType = null;
            Header[] headers = request.getHeaders(HTTPConstants.HEADER_CONTENT_TYPE);
            if (headers != null && headers.length > 0) {
                contentType = headers[0].getValue();
                int index = contentType.indexOf(';');
                if (index > 0) {
                    contentType = contentType.substring(0, index);
                }
            }
           
            // deal with GET request
            pi = RESTUtil.processURLRequest(
                    msgContext,
                    response.getOutputStream(),
                    contentType);

        } else if (method.equals(HTTPConstants.HEADER_POST)) {
            // deal with POST request

            String contentType = request.getContentType();
           
            if (HTTPTransportUtils.isRESTRequest(contentType)) {
                pi = RESTUtil.processXMLRequest(
                        msgContext,
                        request.getInputStream(),
                        response.getOutputStream(),
                        contentType);
            } else {
                String ip = (String)msgContext.getProperty(MessageContext.TRANSPORT_ADDR);
                if (ip != null){
                    uri = ip + uri;
                }
                pi = HTTPTransportUtils.processHTTPPostRequest(
                        msgContext,
                        request.getInputStream(),
                        response.getOutputStream(),
                        contentType,
                        soapAction,
                        uri);
            }

        } else if (method.equals(HTTPConstants.HEADER_PUT)) {

            String contentType = request.getContentType();
            msgContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
           
            pi = RESTUtil.processXMLRequest(
                    msgContext,
                    request.getInputStream(),
                    response.getOutputStream(),
                    contentType);

        } else if (method.equals(HTTPConstants.HEADER_DELETE)) {

            pi = RESTUtil.processURLRequest(
                    msgContext,
                    response.getOutputStream(),
                    null);

        } else {
            throw new MethodNotSupportedException(method + " method not supported");
        }
       
        Boolean holdResponse =
            (Boolean) msgContext.getProperty(RequestResponseTransport.HOLD_RESPONSE);
        if (pi.equals(InvocationResponse.SUSPEND) ||
                (holdResponse != null && Boolean.TRUE.equals(holdResponse))) {
            try {
                ((RequestResponseTransport) msgContext
                        .getProperty(RequestResponseTransport.TRANSPORT_CONTROL)).awaitResponse();
            }
View Full Code Here

TOP

Related Classes of org.apache.axis2.engine.Handler.InvocationResponse

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.