Package org.apache.axis2.jaxws.message

Examples of org.apache.axis2.jaxws.message.Message


        // Note all exceptions are caught and rethrown with a WebServiceException
        try {
            // Create the message
            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
            Message m = mf.create(protocol);

            // Put the fault onto the message
            MethodMarshallerUtils.marshalFaultResponse(throwable,
                                                       marshalDesc,
                                                       operationDesc,
View Full Code Here


    public static XMLFault createXMLFault(Block b, Protocol p) {
        // Because of the requirement that we have a full SOAP envelope structure as
        // the input to the StAXSOAPModelBuilder, we have to have a dummy envelope
        // that wraps our fault.  This will allow the Axiom SOAPFault object to
        // be created.       
        Message m = null;
        try {
            MessageFactory mf = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
            m = mf.create(p);
            m.setBodyBlock(b);
        } catch (XMLStreamException e) {
            throw ExceptionFactory.makeWebServiceException(e);
        }
       
        SOAPEnvelope dummyEnv = (SOAPEnvelope) m.getAsOMElement();       
       
        StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(dummyEnv.getXMLStreamReaderWithoutCaching());
        SOAPEnvelope newEnv = (SOAPEnvelope) builder.getDocumentElement();
       
        SOAPBody body = newEnv.getBody();
View Full Code Here

            log.debug("start placeMessageOnAxis2MessageContext");
        }
        try {
            org.apache.axis2.context.MessageContext mc = jaxwsMC.getAxisMessageContext();
            if (mc != null) {
                Message message = jaxwsMC.getMessage();
                if (message != null) {
                    if (log.isDebugEnabled()) {
                        log.debug("Place the (perhaps new or edited) Message on the MessageContext");
                    }
                    MessageUtils.putMessageOnMessageContext(message, mc);
View Full Code Here

            log.debug(" checkMsg is : " + checkMsg);
        }
          
        try {
            // According to the 9.3.2.1, The message is converted into a fault only if it is not already a Fault
            Message messageFromHandler = null;
            if (checkMsg) {
                messageFromHandler = mepCtx.getMessageContext().getMessage();
            }
            if (messageFromHandler != null && messageFromHandler.isFault()) {
                if (log.isDebugEnabled()) {
                    log.debug("The Message is already a SOAPFault.  The exception is not converted into a Message");
                }
            } else if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
                if (log.isDebugEnabled()) {
                    log.debug("Converting Exception into a Message");
                }
                String protocolNS = (protocol == Protocol.soap11) ?
                        SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE :
                        SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE;

                // The following set of instructions is used to avoid
                // some unimplemented methods in the Axis2 SAAJ implementation
                XMLFault xmlFault = MethodMarshallerUtils.createXMLFaultFromSystemException(e);
                javax.xml.soap.MessageFactory mf = SAAJFactory.createMessageFactory(protocolNS);
                SOAPMessage message = mf.createMessage();
                SOAPBody body = message.getSOAPBody();
                SOAPFault soapFault = XMLFaultUtils.createSAAJFault(xmlFault, body);

                MessageFactory msgFactory = (MessageFactory) FactoryRegistry.getFactory(MessageFactory.class);
                Message msg = msgFactory.createFrom(message);
                mepCtx.setMessage(msg);

            } else {
                WebServiceException wse = ExceptionFactory.makeWebServiceException(Messages.getMessage("cFaultMsgErr"));
                if (log.isDebugEnabled()) {
View Full Code Here

                    MethodMarshallerUtils.getMarshalDesc(endpointDesc);
            TreeSet<String> packages = marshalDesc.getPackages();

            // Create the message
            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
            Message m = mf.create(protocol);

            // Put the return object onto the message
            Class returnType = operationDesc.getResultActualType();
            if (returnType != void.class) {
               
                AttachmentDescription attachmentDesc =
                    operationDesc.getResultAttachmentDescription();
                if (attachmentDesc != null) {
                    if (attachmentDesc.getAttachmentType() == AttachmentType.SWA) {
                        // Create an Attachment object with the signature value
                        Attachment attachment = new Attachment(returnObject,
                                                               returnType,
                                                               attachmentDesc,
                                                               operationDesc.getResultPartName());
                        m.addDataHandler(attachment.getDataHandler(),
                                         attachment.getContentID());
                        m.setDoingSWA(true);
                    } else {
                        throw ExceptionFactory.
                          makeWebServiceException(Messages.getMessage("pdElementErr"));
                    }
                } else {

                    // Use byJavaType marshalling if necessary
                    Class byJavaType = null;
                    if (MethodMarshallerUtils.isNotJAXBRootElement(returnType, marshalDesc)) {
                        byJavaType = returnType;
                    }

                    Element returnElement = null;
                    QName returnQName = new QName(operationDesc.getResultTargetNamespace(),
                                                  operationDesc.getResultName());
                    if (marshalDesc.getAnnotationDesc(returnType).hasXmlRootElement()) {
                        returnElement = new Element(returnObject, returnQName);
                    } else {
                        returnElement = new Element(returnObject, returnQName, returnType);
                    }
                    MethodMarshallerUtils.toMessage(returnElement, returnType, operationDesc.isListType(),
                                                    marshalDesc, m,
                                                    byJavaType,
                                                    operationDesc.isResultHeader());
                }
            }

            // Convert the holder objects into a list of JAXB objects for marshalling
            List<PDElement> pdeList = MethodMarshallerUtils.getPDElements(marshalDesc,
                                                                          pds,
                                                                          signatureArgs,
                                                                          false, // output
                                                                          false, false);

            // We want to use "by Java Type" marshalling for
            // all body elements and all non-JAXB objects
            for (PDElement pde : pdeList) {
                ParameterDescription pd = pde.getParam();
                Class type = pd.getParameterActualType();
                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                    pde.setByJavaTypeClass(type);
                }
            }

            // Put values onto the message
            MethodMarshallerUtils.toMessage(pdeList, m, packages, null);
           
            // Enable SWA for nested SwaRef attachments
            if (operationDesc.hasResponseSwaRefAttachments()) {
                m.setDoingSWA(true);
            }

            return m;
        } catch (Exception e) {
            throw ExceptionFactory.makeWebServiceException(e);
View Full Code Here

                    MethodMarshallerUtils.getMarshalDesc(endpointDesc);
            TreeSet<String> packages = marshalDesc.getPackages();

            // Create the message
            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
            Message m = mf.create(protocol);

            // The input object represent the signature arguments.
            // Signature arguments are both holders and non-holders
            // Convert the signature into a list of JAXB objects for marshalling
            List<PDElement> pdeList = MethodMarshallerUtils.getPDElements(marshalDesc,
                                                                          pds,
                                                                          signatureArguments,
                                                                          true,  // input
                                                                          false, false);

            // We want to use "by Java Type" marshalling for
            // all body elements and all non-JAXB objects
            for (PDElement pde : pdeList) {
                ParameterDescription pd = pde.getParam();
                Class type = pd.getParameterActualType();
                if (MethodMarshallerUtils.isNotJAXBRootElement(type, marshalDesc)) {
                    pde.setByJavaTypeClass(type);
                }
            }

            // Put values onto the message...marshalling by type
            MethodMarshallerUtils.toMessage(pdeList, m, packages, requestContext);
           
            // Enable SWA for nested SwaRef attachments
            if (operationDesc.hasRequestSwaRefAttachments()) {
                m.setDoingSWA(true);
            }

            return m;
        } catch (Exception e) {
            throw ExceptionFactory.makeWebServiceException(e);
View Full Code Here

        // Note all exceptions are caught and rethrown with a WebServiceException
        try {
            // Create the message
            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
            Message m = mf.create(protocol);

            // Put the fault onto the message
            MethodMarshallerUtils.marshalFaultResponse(throwable,
                                                       marshalDesc,
                                                       operationDesc,
View Full Code Here

     * outbound attachment property
     * @param mc MessageContext
     */
    public static void install(MessageContext mc) {
       
        Message m = mc.getMessage();
       
        if (m == null) {
            // Probably a unit test, can't continue.
            return;
        }
View Full Code Here

   
    public void clear() {
        if (log.isDebugEnabled()) {
            log.debug("clear()");
        }
        Message m = mc.getMessage();
        Set<String> keys = this.keySet();
        for(String key: keys) {
            m.removeDataHandler(key);
        }
    }
View Full Code Here

            m.removeDataHandler(key);
        }
    }
   
    public boolean containsKey(Object key) {
        Message m = mc.getMessage();
        Set<String> keys = this.keySet();
        return keys.contains(key);
    }
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.message.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.