Package org.apache.axis2.jaxws.message

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


                    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> pvList = MethodMarshallerUtils.getPDElements(marshalDesc,
                                                                         pds,
                                                                         signatureArguments,
                                                                         true,  // input
                                                                         false, false);

            // Put values onto the message
            MethodMarshallerUtils.toMessage(pvList, 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


        listener.setMode(mode);
        return listener;
    }

    public Message createMessageFromValue(Object value) {
        Message message = null;
       
        if (value == null) {
            if (log.isDebugEnabled()) {
                log.debug("Dispatch invoked with null parameter Value");
                log.debug("creating empty soap message");
            }
            try {
                return createEmptyMessage(
                        Protocol.getProtocolForBinding(endpointDesc.getClientBindingID()));

            } catch (XMLStreamException e) {
                throw ExceptionFactory.makeWebServiceException(e);
            }
        }
       
        try {
            JAXBBlockFactory factory =
                (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);

            Class clazz = value.getClass();
            JAXBBlockContext context = null;
            if (jaxbContext != null) {
                context = new JAXBBlockContext(jaxbContext);
            } else {
                context = new JAXBBlockContext(clazz.getPackage().getName());
            }
            // The protocol of the Message that is created should be based
            // on the binding information available.
            Protocol proto = Protocol.getProtocolForBinding(endpointDesc.getClientBindingID());

            // Create a block from the value
            elementQName = XMLRootElementUtil.getXmlRootElementQNameFromObject(value);
            Block block = factory.createFrom(value, context, elementQName);
            MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);

            if (mode.equals(Mode.PAYLOAD)) {
                // Normal case

                message = mf.create(proto);
                message.setBodyBlock(block);
            } else {
                // Message mode..rare case

                // Create Message from block
                message = mf.createFrom(block, null, proto);
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

    }
   
    private Message createEmptyMessage(Protocol protocol)
            throws WebServiceException, XMLStreamException {
        MessageFactory mf = (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
        Message m = mf.create(protocol);
        return m;
    }   
View Full Code Here

     * @see org.apache.axis2.jaxws.feature.util.WebServiceFeatureConfigurator#performConfiguration(org.apache.axis2.jaxws.core.MessageContext, org.apache.axis2.jaxws.spi.BindingProvider)
     */
    public void configure(MessageContext messageContext, BindingProvider provider) {
        Binding bnd = (Binding) provider.getBinding();
        MTOMFeature mtomFeature = (MTOMFeature) bnd.getFeature(MTOMFeature.ID);
        Message requestMsg = messageContext.getMessage();
       
        //Disable MTOM.
        requestMsg.setMTOMEnabled(false);
               
        if (mtomFeature == null) {
            throw ExceptionFactory.
              makeWebServiceException(Messages.getMessage("mtomFeatureErr"));
        }

        //Enable MTOM if specified.
        if (mtomFeature.isEnabled()) {
            int threshold = mtomFeature.getThreshold();
            List<String> attachmentIDs = requestMsg.getAttachmentIDs();
           
            // Enable MTOM
            requestMsg.setMTOMEnabled(true);
           
            if (threshold <= 0) {
                if (log.isDebugEnabled()) {
                    log.debug("Enabling MTOM with no threshold.");
                }            
View Full Code Here

                    // The behavior was disabled, so instead of creating a SOAPFaultException
                    // just create an empty message and set the local exception on it.  This will cause the
                    // JAX-WS application handler handleMessage() methods to be called with the empty message.
                    MessageFactory factory =
                            (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
                    Message message = factory.create(request.getMessage().getProtocol());
                    response.setLocalException(faultexception);
                    response.setMessage(message);
                }
            }
View Full Code Here

    * of performance.
    */
    private void setupProperties(MessageContext mc) {//, Options ops) {

        // Enable MTOM
        Message msg = mc.getMessage();
        if (msg.isMTOMEnabled()) {
            mc.setProperty(Configuration.ENABLE_MTOM, "true");
        }

        // Enable session management
        if (mc.isMaintainSession()) {
View Full Code Here

            throws WebServiceException {
        if (log.isDebugEnabled()) {
            log.debug("Start getMessageFromMessageContext");
        }

        Message message = null;
        // If the Axis2 MessageContext that was passed in has a SOAPEnvelope
        // set on it, grab that and create a JAX-WS Message out of it.
        SOAPEnvelope soapEnv = msgContext.getEnvelope();
        if (soapEnv != null) {
            MessageFactory msgFactory =
                    (MessageFactory)FactoryRegistry.getFactory(MessageFactory.class);
            try {
                Protocol protocol = msgContext.isDoingREST() ? Protocol.rest : null;
                message = msgFactory.createFrom(soapEnv, protocol);
            } catch (Exception e) {
                throw ExceptionFactory.makeWebServiceException(
                    Messages.getMessage("msgFromMsgErr"), e);
            }

            Object property = msgContext.getProperty(Constants.Configuration.ENABLE_MTOM);
            if (property != null && JavaUtils.isTrueExplicitly(property)) {
                message.setMTOMEnabled(true);
            }

            // Add all the MimeHeaders from the Axis2 MessageContext
            Map headerMap = (Map)msgContext.getProperty(MessageContext.TRANSPORT_HEADERS);
            if (headerMap != null) {
                message.setMimeHeaders(headerMap);
            }
           
            // TODO: This is a WORKAROUND for missing SOAPFault data.  If we do a toString on the
            // SOAPEnvelope, then all the data will be available to the provider.  Otherwise, it
            // will be missing the <Reason> element corresponding to the <faultstring> element. 
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);

            // Indicate the style and wrapper element name.  This triggers the message to
            // put the data blocks underneath the wrapper element
            m.setStyle(Style.DOCUMENT);
            m.setIndirection(1);
            m.setOperationElement(getRequestWrapperQName(operationDesc));

            // 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
                                                        true,  // doc/lit wrapped
                                                        true); // false

            // We want to use "by Java Type" marshalling for
            // all objects
            for (int i=0; i<pdeList.size(); i++) {
               
                PDElement pde = pdeList.get(i);
               
                // If the actual value is an array or list
                // this should be modeled as an
                // occurrence of elements
                pde = processOccurrence(pde);
                pdeList.set(i, pde);
               
                // Set by java type marshaling
                ParameterDescription pd = pde.getParam();
                Class type = pd.getParameterActualType();
                pde.setByJavaTypeClass(type);
            }
           
            // Put values onto the message
            MethodMarshallerUtils.toMessage(pdeList, m, packages, requestContext);
           
            // Enable SWA for nested SwaRef attachments
            if (operationDesc.hasRequestSwaRefAttachments()) {
                m.setDoingSWA(true);
            }

            if (log.isDebugEnabled()) {
                log.debug("exit marshalRequest");
            }
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);

            // Indicate the style and wrapper element name.  This triggers the message to
            // put the data blocks underneath the operation element
            m.setStyle(Style.DOCUMENT);
            m.setIndirection(1);
            QName responseOp = getResponseWrapperQName(operationDesc);
            m.setOperationElement(responseOp);

            // Put the return object onto the message
            Class returnType = operationDesc.getResultActualType();
            String returnNS = null;
            String returnLocalPart = null;
            if (operationDesc.isResultHeader()) {
                returnNS = operationDesc.getResultTargetNamespace();
                returnLocalPart = operationDesc.getResultName();
            } else {
                returnNS = operationDesc.getResultTargetNamespace();
                returnLocalPart = operationDesc.getResultPartName();
            }

            if (returnType != void.class) {
                Element returnElement = null;
                QName returnQName = new QName(returnNS, returnLocalPart);
                if (representAsOccurrence(returnObject, returnType)) {
                    if (log.isDebugEnabled()) {
                        log.debug("Return element isListOrArray");
                    }
                    OccurrenceArray occurrenceArray = new OccurrenceArray(returnObject);
                    JAXBElement jaxb = new JAXBElement(returnQName, returnType, occurrenceArray);
                    returnElement = new Element(jaxb, returnQName);
                } else 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,
                                                returnType, // force marshal by type
                                                operationDesc.isResultHeader());
            }

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

            // We want to use "by Java Type" marshalling for
            // all objects
            for (int i=0; i<pdeList.size(); i++) {
               
                PDElement pde = pdeList.get(i);
               
                // If the actual value is an array or list
                // this should be modeled as an
                // occurrence of elements
                pde = processOccurrence(pde);
                pdeList.set(i, pde);
               
                // Set by java type marshaling
                ParameterDescription pd = pde.getParam();
                Class type = pd.getParameterActualType();
                pde.setByJavaTypeClass(type);
            }

            // TODO Should we check for null output body values?  Should we check for null output header values ?
            // Put values onto the message
            MethodMarshallerUtils.toMessage(pdeList, m, packages, null);
           
            // Enable SWA for nested SwaRef attachments
            if (operationDesc.hasResponseSwaRefAttachments()) {
                m.setDoingSWA(true);
            }

            if (log.isDebugEnabled()) {
                log.debug("exit marshalResponse");
            }
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.