Package org.apache.axis

Examples of org.apache.axis.Message


        if (log.isDebugEnabled()) {
            log.debug(Messages.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


                if(resolver != null)
                   ret = resolver.getReferencedObject(href);
            }
            if( null == ret && !href.startsWith("#")){
                //Could this be an attachment?
                Message msg= null;
                if(null != (msg=msgContext.getCurrentMessage())){
                    Attachments attch= null;
                    if( null != (attch= msg.getAttachmentsImpl())){
                        try{
                        ret= attch.getAttachmentByReference(href);
                        }catch(AxisFault e){
                            throw new RuntimeException(e.toString() + JavaUtils.stackToString(e));
                        }
View Full Code Here

            if ( !(params[0] instanceof SOAPEnvelope) )
                for ( i = 0 ; i < params.length ; i++ )
                    env.addBodyElement( (SOAPBodyElement) params[i] );

            Message msg = new Message( env );
            setRequestMessage(msg);

            invoke();

            msg = msgContext.getResponseMessage();
            if (msg == null) {
              if (FAULT_ON_NO_RESPONSE) {
                throw new AxisFault(Messages.getMessage("nullResponse00"));
              } else {
                return null;
              }
            }

            env = msg.getSOAPEnvelope();
            return( env.getBodyElements() );
        }


        if ( operationName == null )
View Full Code Here

     * @exception AxisFault
     */
    public SOAPEnvelope invoke(SOAPEnvelope env)
                                  throws java.rmi.RemoteException {
        try {
            Message msg = null ;

            msg = new Message( env );
            setRequestMessage( msg );
            invoke();
            msg = msgContext.getResponseMessage();
            if (msg == null) {
              if (this.FAULT_ON_NO_RESPONSE) {
                throw new AxisFault(Messages.getMessage("nullResponse00"));
              } else {
                return null;
              }
            }
            return( msg.getSOAPEnvelope() );
        }
        catch( Exception exp ) {
            if ( exp instanceof AxisFault ) throw (AxisFault) exp ;

            entLog.info(Messages.getMessage("toAxisFault00"), exp);
View Full Code Here

            log.error(Messages.getMessage("mustSpecifyReturnType"));
        }

        SOAPEnvelope         reqEnv = new SOAPEnvelope(msgContext.getSOAPConstants());
        SOAPEnvelope         resEnv = null ;
        Message              reqMsg = new Message( reqEnv );
        Message              resMsg = null ;
        Vector               resArgs = null ;
        Object               result = null ;

        // Clear the output params
        outParams = new HashMap();
        outParamsList = new ArrayList();

        // Set both the envelope and the RPCElement encoding styles
        try {
            body.setEncodingStyle(getEncodingStyle());

            setRequestMessage(reqMsg);

            reqEnv.addBodyElement(body);
            reqEnv.setMessageType(Message.REQUEST);

            invoke();
        } catch (Exception e) {
            entLog.info(Messages.getMessage("toAxisFault00"), e);
            throw AxisFault.makeFault(e);
        }

        resMsg = msgContext.getResponseMessage();

        if (resMsg == null) {
          if (FAULT_ON_NO_RESPONSE) {
            throw new AxisFault(Messages.getMessage("nullResponse00"));
          } else {
            return null;
          }
        }

        resEnv = (SOAPEnvelope)resMsg.getSOAPEnvelope();
        SOAPBodyElement bodyEl = resEnv.getFirstBody();
        if (bodyEl instanceof RPCElement) {
            try {
                resArgs = ((RPCElement) bodyEl).getParams();
            } catch (Exception e) {
View Full Code Here

    public void invoke() throws AxisFault {
        if (log.isDebugEnabled()) {
            log.debug("Enter: Call::invoke()");
        }

        Message      reqMsg  = null ;
        SOAPEnvelope reqEnv  = null ;

        msgContext.reset();
        msgContext.setResponseMessage(null);
        msgContext.setProperty( MessageContext.CALL, this );
        msgContext.setProperty( WSDL_SERVICE, service );
        msgContext.setProperty( WSDL_PORT_NAME, getPortName() );
        if ( isMsg )
          msgContext.setProperty( MessageContext.IS_MSG, "true" );

        if (username != null) {
            msgContext.setUsername(username);
        }
        if (password != null) {
            msgContext.setPassword(password);
        }
        msgContext.setMaintainSession(maintainSession);

        msgContext.setOperation(operation);

        operation.setStyle(getOperationStyle());
        msgContext.setOperationStyle(getOperationStyle());

        if (useSOAPAction) {
            msgContext.setUseSOAPAction(true);
        }
        if (SOAPActionURI != null) {
            msgContext.setSOAPActionURI(SOAPActionURI);
        }
        if (timeout != null) {
            msgContext.setTimeout(timeout.intValue());
        }

        // Determine client target service
        if (myService != null) {
            // If we have a SOAPService kicking around, use that directly
            msgContext.setService(myService);
        } else {
            if (portName != null) {
                // No explicit service.  If we have a target service name,
                // try that.
                msgContext.setTargetService(portName.getLocalPart());
            } else {
                // No direct config, so try the namespace of the first body.
                reqMsg = msgContext.getRequestMessage();
                reqEnv = reqMsg.getSOAPEnvelope();

                SOAPBodyElement body = reqEnv.getFirstBody();

                // Does this make any sense to anyone?  If not, we should remove it.
                // --Glen 03/16/02
View Full Code Here

        service.getEngine().invoke( msgContext );

        if (transport != null)
            transport.processReturnedMessageContext(msgContext);

        Message resMsg = msgContext.getResponseMessage();

        if (resMsg == null) {
          if (this.FAULT_ON_NO_RESPONSE) {
            throw new AxisFault(Messages.getMessage("nullResponse00"));
          } else {
            return;
          }
        }

        /** This must happen before deserialization...
         */
        resMsg.setMessageType(Message.RESPONSE);

        SOAPEnvelope resEnv = (SOAPEnvelope)resMsg.getSOAPEnvelope();

        SOAPBodyElement respBody = resEnv.getFirstBody();
        if (respBody instanceof SOAPFault) {
            throw ((SOAPFault)respBody).getFault();
        }
View Full Code Here

                    // It's possible that we haven't yet parsed the
                    // message at this point.  This is a kludge to
                    // make sure we have.  There probably wants to be
                    // some kind of declarative "parse point" on the handler
                    // chain instead....
                    Message rm = msgContext.getRequestMessage();
                    rm.getSOAPEnvelope().getFirstBody();
                    h = msgContext.getService();
                    if (h == null)
                        throw new AxisFault("Server.NoService",
                                            Messages.getMessage("noService05",
                                                                 "" + msgContext.getTargetService()),
View Full Code Here

                    // It's possible that we haven't yet parsed the
                    // message at this point.  This is a kludge to
                    // make sure we have.  There probably wants to be
                    // some kind of declarative "parse point" on the handler
                    // chain instead....
                    Message rm = msgContext.getRequestMessage();
                    if (rm != null) {
                        rm.getSOAPEnvelope().getFirstBody();
                        h = msgContext.getService();
                    }
                    if (h == null)
                        throw new AxisFault(Constants.QNAME_NO_SERVICE_FAULT_CODE,
                                            Messages.getMessage("noService05",
View Full Code Here

                    : tmpURL.getFile()));
        }



        Message reqMessage = msgContext.getRequestMessage();

        boolean http10 = true; //True if this is to use HTTP 1.0 / false HTTP 1.1
        boolean httpChunkStream = false; //Use HTTP chunking or not.
        boolean httpContinueExpected = false; //Under HTTP 1.1 if false you *MAY* need to wait for a 100 rc,
                                              //  if true the server MUST reply with 100 continue.
        String httpConnection = null;

        String httpver = msgContext.getStrProp(MessageContext.HTTP_TRANSPORT_VERSION);
        if (null == httpver) httpver = HTTPConstants.HEADER_PROTOCOL_V10;
        httpver = httpver.trim();
        if (httpver.equals(HTTPConstants.HEADER_PROTOCOL_V11)) {
            http10 = false;
        }

        //process user defined headers for information.
        Hashtable userHeaderTable = (Hashtable) msgContext.
                getProperty(HTTPConstants.REQUEST_HEADERS);

        if (userHeaderTable != null) {
            if (null == otherHeaders) otherHeaders = new StringBuffer(1024);

            for (java.util.Iterator e = userHeaderTable.entrySet().iterator();
                 e.hasNext();) {

                java.util.Map.Entry me = (java.util.Map.Entry) e.next();
                Object keyObj = me.getKey();
                if (null == keyObj) continue;
                String key = keyObj.toString().trim();

                if (key.equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING)) {
                    if (!http10) {
                        String val = me.getValue().toString();
                        if (null != val && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED))
                            httpChunkStream = true;
                    }
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_HOST)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONTENT_TYPE)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_SOAP_ACTION)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONTENT_LENGTH)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_COOKIE)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_COOKIE2)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_AUTHORIZATION)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_PROXY_AUTHORIZATION)) {
                    //ignore
                } else if (key.equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION)) {
                    if (!http10) {
                        String val = me.getValue().toString();
                        if (val.trim().equalsIgnoreCase(HTTPConstants.HEADER_CONNECTION_CLOSE))
                            httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE;
                    }
                    //HTTP 1.0 will always close.
                    //HTTP 1.1 will use persistent. //no need to specify
                } else {
                    if( !http10 && key.equalsIgnoreCase(HTTPConstants.HEADER_EXPECT)) {
                        String val = me.getValue().toString();
                        if (null != val && val.trim().equalsIgnoreCase(HTTPConstants.HEADER_EXPECT_100_Continue))
                            httpContinueExpected = true;
                    }

                    otherHeaders.append(key).append(": ").append(me.getValue()).append("\r\n");
                }
            }
        }

        if (!http10)
            httpConnection = HTTPConstants.HEADER_CONNECTION_CLOSE; //Force close for now.

        header.append(" ");
        header.append(http10 ? HTTPConstants.HEADER_PROTOCOL_10 :
                HTTPConstants.HEADER_PROTOCOL_11)
                .append("\r\n")
                .append(HTTPConstants.HEADER_CONTENT_TYPE)
                .append(": ")
                .append(reqMessage.getContentType(msgContext.getSOAPConstants()))
                .append("\r\n")
                .append( HTTPConstants.HEADER_ACCEPT ) //Limit to the types that are meaningful to us.
                .append( ": ")
                .append( HTTPConstants.HEADER_ACCEPT_APPL_SOAP)
                .append( ", ")
                .append( HTTPConstants.HEADER_ACCEPT_APPLICATION_DIME)
                .append( ", ")
                .append( HTTPConstants.HEADER_ACCEPT_MULTIPART_RELATED)
                .append( ", ")
                .append( HTTPConstants.HEADER_ACCEPT_TEXT_ALL)
                .append("\r\n")
                .append(HTTPConstants.HEADER_USER_AGENT)   //Tell who we are.
                .append( ": ")
                .append(Constants.AXIS_VERSION)
                .append("\r\n")
                .append(HTTPConstants.HEADER_HOST//used for virtual connections
                .append(": ")
                .append(host)
                .append((port == -1)?(""):(":" + port))
                .append("\r\n")
                .append(HTTPConstants.HEADER_CACHE_CONTROL)   //Stop caching proxies from caching SOAP reqeuest.
                .append(": ")
                .append(HTTPConstants.HEADER_CACHE_CONTROL_NOCACHE)
                .append("\r\n")
                .append(HTTPConstants.HEADER_PRAGMA)
                .append(": ")
                .append(HTTPConstants.HEADER_CACHE_CONTROL_NOCACHE)
                .append("\r\n")
                .append(HTTPConstants.HEADER_SOAP_ACTION//The SOAP action.
                .append(": \"")
                .append(action)
                .append("\"\r\n");

        if (!httpChunkStream) {
            //Content length MUST be sent on HTTP 1.0 requests.
            header.append(HTTPConstants.HEADER_CONTENT_LENGTH)
                    .append(": ")
                    .append(reqMessage.getContentLength())
                    .append("\r\n");
        } else {
            //Do http chunking.
            header.append(HTTPConstants.HEADER_TRANSFER_ENCODING)
                    .append(": ")
                    .append(HTTPConstants.HEADER_TRANSFER_ENCODING_CHUNKED)
                    .append("\r\n");
        }

        if (null != httpConnection) {
            header.append(HTTPConstants.HEADER_CONNECTION);
            header.append(": ");
            header.append(httpConnection);
            header.append("\r\n");
        }

        if (null != otherHeaders)
            header.append(otherHeaders); //Add other headers to the end.


        header.append("\r\n"); //The empty line to start the BODY.

        OutputStream out = sock.getOutputStream();

        if (httpChunkStream) {
            out.write(header.toString()
                    .getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
            if(httpContinueExpected ){ //We need to get a reply from the server as to whether
                                      // it wants us send anything more.
                out.flush();
                Hashtable cheaders= new Hashtable ();
                inp=readFromSocket(sock, msgContext, null, cheaders);
                int returnCode= -1;
                Integer Irc= (Integer)msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
                if(null != Irc) returnCode= Irc.intValue();
                if(100 == returnCode){  // got 100 we may continue.
                    //Need todo a little msgContext house keeping....
                    msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
                    msgContext.removeProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);
                }
                else{ //If no 100 Continue then we must not send anything!
                    String statusMessage= (String)
                        msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);

                    AxisFault fault = new AxisFault("HTTP", "(" + returnCode+ ")" + statusMessage, null, null);

                    fault.setFaultDetailString(Messages.getMessage("return01",
                            "" + returnCode, ""));
                    throw fault;
               }


            }
            ChunkedOutputStream chunkedOutputStream = new ChunkedOutputStream(out);
            out = new BufferedOutputStream(chunkedOutputStream, 8 * 1024);
            try {
                reqMessage.writeTo(out);
            } catch (SOAPException e) {
                log.error(Messages.getMessage("exception00"), e);
            }
            out.flush();
            chunkedOutputStream.eos();
        } else {
            //No chunking...
            if(httpContinueExpected ){ //We need to get a reply from the server as to whether
                                      // it wants us send anything more.
                out.flush();
                Hashtable cheaders= new Hashtable ();
                inp=readFromSocket(sock, msgContext, null, cheaders);
                int returnCode= -1;
                Integer Irc=  (Integer) msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE);
                if(null != Irc) returnCode= Irc.intValue();
                if(100 == returnCode){  // got 100 we may continue.
                    //Need todo a little msgContext house keeping....
                    msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
                            null);
                    msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE,
                            null);
                }
                else{ //If no 100 Continue then we must not send anything!
                    String statusMessage= (String)
                        msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_MESSAGE);

                    AxisFault fault = new AxisFault("HTTP", "(" + returnCode+ ")" + statusMessage, null, null);

                    fault.setFaultDetailString(Messages.getMessage("return01",
                            "" + returnCode, ""));
                    throw fault;
               }


            }
            out = new BufferedOutputStream(out, 8 * 1024);
            try {
                out.write(header.toString()
                        .getBytes(HTTPConstants.HEADER_DEFAULT_CHAR_ENCODING));
                reqMessage.writeTo(out);
            } catch (SOAPException e) {
                log.error(Messages.getMessage("exception00"), e);
            }
            // Flush ONLY once.
            out.flush();
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.