Package org.apache.axis

Examples of org.apache.axis.Message


         Document signedDoc = sigBuilder.build(doc, secHeader);
        
         encrKeyBuilder.prependToHeader(secHeader);
         encrKeyBuilder.prependBSTElementToHeader(secHeader);
        
         Message signedMessage = (Message) SOAPUtil.toSOAPMessage(doc);
         if (log.isDebugEnabled()) {
             log.debug("Encrypted message: 3DES  + DerivedKeys");
             XMLUtils.PrettyElementToWriter(signedMessage.getSOAPEnvelope()
                    .getAsDOM(), new PrintWriter(System.out));
         }
//         String out = org.apache.ws.security.util.XMLUtils
//                .PrettyDocumentToString(signedDoc);
//        System.out.println(out);
View Full Code Here


        Document signedEncryptedDoc = encrBuilder.build(signedDoc, secHeader);

        encrKeyBuilder.prependToHeader(secHeader);
        encrKeyBuilder.prependBSTElementToHeader(secHeader);

        Message signedMessage = (Message) SOAPUtil
                .toSOAPMessage(signedEncryptedDoc);

        if (log.isDebugEnabled()) {
            log.debug("Encrypted message: 3DES  + DerivedKeys");
            XMLUtils.PrettyElementToWriter(signedMessage.getSOAPEnvelope()
                    .getAsDOM(), new PrintWriter(System.out));
        }
//        String out = org.apache.ws.security.util.XMLUtils
//                .PrettyDocumentToString(signedEncryptedDoc);
//        System.out.println(out);
View Full Code Here

         Document encryptedSignedDoc = sigBuilder.build(doc, secHeader);
        
         encrKeyBuilder.prependToHeader(secHeader);
         encrKeyBuilder.prependBSTElementToHeader(secHeader);
        
         Message signedMessage = (Message) SOAPUtil
                .toSOAPMessage(encryptedSignedDoc);
        
         if (log.isDebugEnabled()) {
            log.debug("Encrypted message: 3DES  + DerivedKeys");
            XMLUtils.PrettyElementToWriter(signedMessage.getSOAPEnvelope()
                    .getAsDOM(), new PrintWriter(System.out));
        }
       
//         String out = org.apache.ws.security.util.XMLUtils
//                .PrettyDocumentToString(encryptedSignedDoc);
View Full Code Here

            log.debug("Enter: doPost()");
        if( tlog.isDebugEnabled() ) {
            t0=System.currentTimeMillis();
        }

        Message responseMsg = null;

        try {
            AxisEngine engine = getEngine();

            if (engine == null) {
                // !!! should return a SOAP fault...
                ServletException se =
                    new ServletException(JavaUtils.getMessage("noEngine00"));
                log.debug("No Engine!", se);
                throw se;
            }

            res.setBufferSize(1024 * 8); // provide performance boost.

            /** get message context w/ various properties set
             */
            msgContext = createMessageContext(engine, req, res);

            // ? OK to move this to 'getMessageContext',
            // ? where it would also be picked up for 'doGet()' ?
            if (securityProvider != null) {
                if (isDebug) log.debug("securityProvider:" + securityProvider);
                msgContext.setProperty("securityProvider", securityProvider);
            }

            /* Get request message
             */
            Message requestMsg =
                new Message(req.getInputStream(),
                            false,
                            req.getHeader(HTTPConstants.HEADER_CONTENT_TYPE),
                            req.getHeader(HTTPConstants.HEADER_CONTENT_LOCATION));

            if(isDebug) log.debug("Request Message:" + requestMsg);

            /* Set the request(incoming) message field in the context */
            /**********************************************************/
            msgContext.setRequestMessage(requestMsg);

            try {
                /**
                 * Save the SOAPAction header in the MessageContext bag.
                 * This will be used to tell the Axis Engine which service
                 * is being invoked.  This will save us the trouble of
                 * having to parse the Request message - although we will
                 * need to double-check later on that the SOAPAction header
                 * does in fact match the URI in the body.
                 */
                // (is this last stmt true??? (I don't think so - Glen))
                /********************************************************/
                soapAction = getSoapAction(req);

                if (soapAction != null) {
                    msgContext.setUseSOAPAction(true);
                    msgContext.setSOAPActionURI(soapAction);
                }

                // Create a Session wrapper for the HTTP session.
                // These can/should be pooled at some point.
                // (Sam is Watching! :-)
                msgContext.setSession(new AxisHttpSession(req));

                if( tlog.isDebugEnabled() ) {
                    t1=System.currentTimeMillis();
                }
                /* Invoke the Axis engine... */
                /*****************************/
                if(isDebug) log.debug("Invoking Axis Engine.");
                engine.invoke(msgContext);
                if(isDebug) log.debug("Return from Axis Engine.");
                if( tlog.isDebugEnabled() ) {
                    t2=System.currentTimeMillis();
                }

                responseMsg = msgContext.getResponseMessage();
            } catch (AxisFault e) {
                log.error(JavaUtils.getMessage("exception00"), e);
                // It's been suggested that a lack of SOAPAction
                // should produce some other error code (in the 400s)...
                int status = getHttpServletResponseStatus(e);
                if (status == HttpServletResponse.SC_UNAUTHORIZED)
                  res.setHeader("WWW-Authenticate","Basic realm=\"AXIS\"");
                  // TODO: less generic realm choice?
                res.setStatus(status);
                responseMsg = new Message(e);
            } catch (Exception e) {
                log.error(JavaUtils.getMessage("exception00"), e);
                res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                responseMsg = new Message(AxisFault.makeFault(e));
            }
        } catch (AxisFault fault) {
            log.error(JavaUtils.getMessage("axisFault00"), fault);
            responseMsg = new Message(fault);
        }
        if( tlog.isDebugEnabled() ) {
            t3=System.currentTimeMillis();
        }

View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug(JavaUtils.getMessage("sendingXML00", "LocalSender"));
            log.debug(msgStr);
        }

        serverContext.setRequestMessage(new Message(msgStr));
        serverContext.setTransportName("local");

        // Also copy authentication info if present
        String user = clientContext.getUsername();
        if (user != null) {
            serverContext.setUsername(user);
            String pass = clientContext.getPassword();
            if (pass != null)
                serverContext.setPassword(pass);
        }

        // set the realpath if possible
        String transURL = clientContext.getStrProp(MessageContext.TRANS_URL);
        if (transURL != null) {
            try {
                URL url = new URL(transURL);
                String file = url.getFile();
                if (file.length()>0 && file.charAt(0)=='/') file = file.substring(1);
                serverContext.setProperty(Constants.MC_REALPATH, file);
               
                // This enables "local:///AdminService" and the like to work.
                serverContext.setTargetService(file);
            } catch (Exception e) {
                throw AxisFault.makeFault(e);
            }
        }

        // If we've been given an explicit "remote" service to invoke,
        // use it. (Note that right now this overrides the setting above;
        // is this the correct precedence?)
        String remoteService = clientContext.getStrProp(LocalTransport.REMOTE_SERVICE);
        if (remoteService != null)
            serverContext.setTargetService(remoteService);

        // invoke the request
        try {
            targetServer.invoke(serverContext);
        } catch (AxisFault fault) {
            Message respMsg = serverContext.getResponseMessage();
            if (respMsg == null) {
                respMsg = new Message(fault);
                serverContext.setResponseMessage(respMsg);
            } else {
                SOAPFault faultEl = new SOAPFault(fault);
                SOAPEnvelope env = respMsg.getSOAPEnvelope();
                env.clearBody();
                env.addBodyElement(faultEl);
            }
        }
View Full Code Here

    * Extract the fault string from the Soap Response
    *
    **/
    String getFaultString(MessageContext msgContext) {
      String stRetval = null;
      Message message = msgContext.getResponseMessage();
      try {
          if (message != null) {
            SOAPBody oBody  = message.getSOAPEnvelope().getBody();
            stRetval = oBody.getFault().getFaultString();
          }
      }
      catch (javax.xml.soap.SOAPException e) {
          assertTrue("Unforseen soap exception", false);
View Full Code Here

                conn = getConnection(state, host, port);
            }
            PostMethod method = new PostMethod(targetURL.getFile());

            addContextInfo(method, conn, state, msgContext, targetURL);
            Message reqMessage = msgContext.getRequestMessage();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            reqMessage.writeTo(baos);
            method.setRequestBody(new String(baos.toByteArray()));
            method.execute(state, conn);
            int returnCode = method.getStatusCode();
            String contentType = null;
            String contentLocation = null;
            String contentLength = null;

            if (method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE)
                    != null) {
                contentType = method.getResponseHeader(
                        HTTPConstants.HEADER_CONTENT_TYPE).getValue();
            }
            if (method.getResponseHeader(HTTPConstants.HEADER_CONTENT_LOCATION)
                    != null) {
                contentLocation = method.getResponseHeader(
                        HTTPConstants.HEADER_CONTENT_LOCATION).getValue();
            }
            if (method.getResponseHeader(HTTPConstants.HEADER_CONTENT_LENGTH)
                    != null) {
                contentLength = method.getResponseHeader(
                        HTTPConstants.HEADER_CONTENT_LENGTH).getValue();
            }
            contentType = (null == contentType)
                    ? null
                    : contentType.trim();
            if ((returnCode > 199) && (returnCode < 300)) {

                // SOAP return is OK - so fall through
            } else if ((contentType != null) && !contentType.equals("text/html")
                    && ((returnCode > 499) && (returnCode < 600))) {

                // SOAP Fault should be in here - so fall through
            } else {
                String statusMessage = method.getStatusText();
                AxisFault fault = new AxisFault("HTTP",
                        "(" + returnCode + ")"
                        + statusMessage, null,
                        null);

                fault.setFaultDetailString(JavaUtils.getMessage("return01",
                        "" + returnCode, method.getResponseBodyAsString()));
                throw fault;
            }
            Message outMsg = new Message(method.getResponseBodyAsStream(),
                    false, contentType, contentLocation);

            outMsg.setMessageType(Message.RESPONSE);
            msgContext.setResponseMessage(outMsg);
            if (log.isDebugEnabled()) {
                if (null == contentLength) {
                    log.debug("\n"
                            + JavaUtils.getMessage("no00", "Content-Length"));
                }
                log.debug("\n" + JavaUtils.getMessage("xmlRecd00"));
                log.debug("-----------------------------------------------");
                log.debug((String) outMsg.getSOAPPartAsString());
            }

            // if we are maintaining session state,
            // handle cookies (if any)
            if (msgContext.getMaintainSession()) {
View Full Code Here

                : "";

        if (action == null) {
            action = "";
        }
        Message msg = msgContext.getRequestMessage();
        method.setRequestHeader(new Header(HTTPConstants.HEADER_CONTENT_TYPE,
                msg.getContentType(msgContext.getSOAPConstants())));
        method.setRequestHeader(new Header(HTTPConstants.HEADER_SOAP_ACTION, "\"" + action + "\""));
        method.setUseDisk(false);
        String userID = msgContext.getUsername();
        String passwd = msgContext.getPassword();
View Full Code Here

        MessageContext msgContext = context.getMessageContext();

        // Figure out if we should be looking for out params or in params
        // (i.e. is this message a response?)
        Message msg = msgContext.getCurrentMessage();
        boolean isResponse = ((msg != null) &&
                              Message.RESPONSE.equals(msg.getMessageType()));

        // We're going to need this below, so create one.
        RPCHandler rpcHandler = new RPCHandler(this, isResponse);

        if (operations != null && !msgContext.isClient()) {
View Full Code Here

    public void invoke(MessageContext msgContext) throws AxisFault {
        log.debug("Enter: EchoHandler::invoke");
        try {
            // log.debug("IN MD5");       
            Message  msg = msgContext.getRequestMessage();
            org.apache.axis.message.SOAPEnvelope env = (org.apache.axis.message.SOAPEnvelope) msg.getSOAPEnvelope();
            org.apache.axis.message.SOAPBodyElement sbe = env.getFirstBody();//env.getBodyByName("ns1", "addedfile");
            org.w3c.dom.Element sbElement = sbe.getAsDOM();
            //get the first level accessor  ie parameter
            org.w3c.dom.Node n = sbElement.getFirstChild();

            for (; n != null && !(n instanceof org.w3c.dom.Element); n = n.getNextSibling());
            org.w3c.dom.Element paramElement = (org.w3c.dom.Element) n;
            //Get the href associated with the attachment.
            String href = paramElement.getAttribute(org.apache.axis.Constants.ATTR_HREF);
            org.apache.axis.Part ap = msg.getAttachmentsImpl().getAttachmentByReference(href);
            javax.activation.DataHandler dh = org.apache.axis.attachments.AttachmentUtils.getActivationDataHandler(ap);
            org.w3c.dom.Node timeNode = paramElement.getFirstChild();
            long startTime = -1;

            if (timeNode != null && timeNode instanceof org.w3c.dom.Text) {
                String startTimeStr = ((org.w3c.dom.Text) timeNode).getData();

                startTime = Long.parseLong(startTimeStr);
            }
            // log.debug("GOTIT");

            long receivedTime = System.currentTimeMillis();
            long elapsedTime = -1;

            // log.debug("startTime=" + startTime);
            // log.debug("receivedTime=" + receivedTime);           
            if (startTime > 0) elapsedTime = receivedTime - startTime;
            String elapsedTimeStr = elapsedTime + "";
            // log.debug("elapsedTimeStr=" + elapsedTimeStr);           

            java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
            java.io.InputStream attachmentStream =  dh.getInputStream();
            int bread = 0;
            byte[] buf = new byte[64 * 1024];

            do {
                bread = attachmentStream.read(buf);
                if (bread > 0) {
                    md.update(buf, 0, bread);
                }
            }
            while (bread > -1);
            attachmentStream.close();
            buf = null;
            //Add the mime type to the digest.
            String contentType = dh.getContentType();

            if (contentType != null && contentType.length() != 0) {
                md.update( contentType.getBytes("US-ASCII"));
            }

            sbe = env.getFirstBody();
            sbElement = sbe.getAsDOM();
            //get the first level accessor  ie parameter
            n = sbElement.getFirstChild();
            for (; n != null && !(n instanceof org.w3c.dom.Element); n = n.getNextSibling());
            paramElement = (org.w3c.dom.Element) n;
            // paramElement.setAttribute(org.apache.axis.Constants.ATTR_HREF, respHref);
            String MD5String = org.apache.axis.encoding.Base64.encode(md.digest());
            String senddata = " elapsedTime=" + elapsedTimeStr + " MD5=" + MD5String;

            // log.debug("senddata=" + senddata);           
            paramElement.appendChild( paramElement.getOwnerDocument().createTextNode(senddata));

            sbe = new org.apache.axis.message.SOAPBodyElement(sbElement);
            env.clearBody();
            env.addBodyElement(sbe);
            msg = new Message( env );

            msgContext.setResponseMessage( msg );
        }
        catch ( Exception e ) {
            log.error( JavaUtils.getMessage("exception00"), e );
View Full Code Here

TOP

Related Classes of org.apache.axis.Message

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.