Package org.apache.axis2.jaxws.message

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


            if (om.getNamespace().getNamespaceURI().equals(namespace) &&
                om.getLocalName().equals(localPart)) {
                // _getBlockFromOMElement may replace the current element; move the iterator to the
                // next element to avoid ConcurrentModificationException
                it.hasNext();
                Block block = _getBlockFromOMElement(om, context, blockFactory, false);
                blocks.add(block);
            }
        }
        return blocks;
    }
View Full Code Here


              return newBlock;
              }
              */

            // Create the block
            Block block = blockFactory.createFrom(om, context, qName);
            block.setParent(getParent());
            if (om instanceof SOAPHeaderBlock) {
                block.setProperty(SOAPHeaderBlock.ROLE_PROPERTY, role);
            }

            // Get the business object to force a parse
            block.getBusinessObject(false);

            if (!(om instanceof SOAPFault)) {
                // Replace the OMElement with the OMSourcedElement that delegates to the block. Note that
                // this can be done for plain OMElements and SOAPHeaderBlocks, but not SOAPFaults.
                OMElement newOM = _createOMElementFromBlock(qName.getLocalPart(), ns, block, soapFactory,
View Full Code Here

            } catch (XMLStreamException e) {
                throw ExceptionFactory.makeWebServiceException(e);
            }

        }
        Block block = null;
        blockFactoryType = getBlockFactory(value);
        BlockFactory factory = (BlockFactory)FactoryRegistry.getFactory(blockFactoryType);
        if (log.isDebugEnabled()) {
            log.debug("Loaded block factory type [" + blockFactoryType.getName());
        }
View Full Code Here

     * @param message
     * @return object
     */
    static Object getValue(Message message, Mode mode, Class blockFactoryType) {
        Object value = null;
        Block block = null;

        if (log.isDebugEnabled()) {
            log.debug("Attempting to get the value object from the returned message");
        }

        try {
            if (mode.equals(Mode.PAYLOAD)) {
                BlockFactory factory = (BlockFactory)FactoryRegistry
                        .getFactory(blockFactoryType);
                block = message.getBodyBlock(null, factory);
                if (block != null) {
                    value = block.getBusinessObject(true);
                } else {
                    // REVIEW This seems like the correct behavior.  If the body is empty, return a null
                    // Any changes here should also be made to XMLDispatch.getValue
                    if (log.isDebugEnabled()) {
                        log.debug(
View Full Code Here

            }
           
            // Get the strings from the blocks
            ArrayList<String> xmlStrings = new ArrayList<String>();
            for (int i=0; i<blocks.size(); i++) {
                Block block = blocks.get(i);
                String value = (block == null) ? null : (String) block.getBusinessObject(false);
                xmlStrings.add(value);
            }
           
            return xmlStrings;
        } catch (Throwable t) {
View Full Code Here

                // Replace the existing header blocks
                m.removeHeaderBlock(key.getNamespaceURI(), key.getLocalPart());
            }
            for (int i=0; i < values.size(); i++) {
                String value = values.get(i);
                Block block = getXMLStringBlockFactory().createFrom(value, null, key);
                m.appendHeaderBlock(key.getNamespaceURI(), key.getLocalPart(), block);
            }
        }
       
        return old;
View Full Code Here

            // 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
View Full Code Here

            if (mode.equals(Mode.PAYLOAD)) {
                // Normal Case
                JAXBBlockFactory factory =
                        (JAXBBlockFactory)FactoryRegistry.getFactory(JAXBBlockFactory.class);
                JAXBBlockContext context = new JAXBBlockContext(jaxbContext);
                Block block = message.getBodyBlock(context, factory);

                if (block != null) {
                    value = block.getBusinessObject(true);
                } else {
                    // REVIEW This seems like the correct behavior.  If the body is empty, return a null
                    // Any changes here should also be made to XMLDispatch.getValue
                    if (log.isDebugEnabled()) {
                        log.debug(
View Full Code Here

                // TODO
                //if (isAsyncHandler(param)) {
                //    continue;
                //}

                Block block = null;
                JAXBBlockContext context = new JAXBBlockContext(packages);

                AttachmentDescription attachmentDesc = pd.getAttachmentDescription();
                if (attachmentDesc == null) {
                   
                    boolean isBase64Binary = byte[].class.equals(javaType[i]);
                   
                   
                    // In most cases the entire java object is unmarshalled.
                    // But in some cases, the java object is a series of
                    // elements.
                    boolean unmarshalComponents = false;
                    if (pd.isListType() ||
                        javaComponentType[i] == null ||
                        isBase64Binary) {
                        context.setProcessType(javaType[i]);
                        context.setIsxmlList(pd.isListType());
                    } else {
                        context.setProcessType(javaComponentType[i]);
                        unmarshalComponents = true;
                    }
                   
                   
                    // Unmarshal the object into a JAXB object or JAXBElement
                    Element element = null;
                    if (pd.isHeader()) {
                       
                        if (log.isDebugEnabled()) {
                            log.debug("  get block from the headers");
                        }
                        // Get the Block from the header
                        // NOTE The parameter name is always used to get the header
                        // element
                        String localName = pd.getParameterName();
                        block = message.getHeaderBlock(pd.getTargetNamespace(),
                                                       localName,
                                                       context,
                                                       factory);
                        element = new Element(block.getBusinessObject(true),
                                block.getQName());
                    } else if (firstIndex[i] >= 0) {
                        if (log.isDebugEnabled()) {
                            log.debug("  get block from the " + firstIndex[i] +
                                    " to the " + lastIndex[i]);
                        }
                        // You must use this method if there are more than one body block
                        // This method may cause OM expansion
                        if (unmarshalComponents) {
                            Object container = makeContainer(javaType[i],
                                    javaComponentType[i],
                                    (lastIndex[i] - firstIndex[i]) + 1);

                            for (int blockI=firstIndex[i]; blockI<=lastIndex[i]; blockI++) {
                                block = message.getBodyBlock(blockI, context, factory);
                                Object value = block.getBusinessObject(true);
                                if (value instanceof JAXBElement) {
                                    value = ((JAXBElement) value).getValue();
                                }
                                if (log.isDebugEnabled()) {
                                    log.debug(" get Business Object " + JavaUtils.getObjectIdentity(value) + " from block " + blockI);

                                }

                                addComponent(container, value, blockI - firstIndex[i]);
                               
                            }
                            element = new Element(container,    
                                    block.getQName());

                        } else {
                            block = message.getBodyBlock(firstIndex[i], context, factory);
                            element = new Element(block.getBusinessObject(true),
                                    block.getQName());
                        }
                    }  else {
                        // Missing parameter
                        if (log.isDebugEnabled()) {
                            log.debug("  there is no block for this parameter.");
View Full Code Here

       
        Element returnElement = null;
        if (isHeader) {
           
            // In header
            Block block = message.getHeaderBlock(headerNS, headerLocalPart, context, factory);
            // Get the business object.  We want to return the object that represents the type.
            returnElement = new Element(block.getBusinessObject(true), block.getQName());
        }
        else {
            // In Body
           
            // Determine how many return elements are present
            int numBodyBlocks = message.getNumBodyBlocks();
            if (outputBodyArgIndex >= 0) {
                numBodyBlocks = outputBodyArgIndex;
            }
            if (!unmarshalComponents) {
                if (numBodyBlocks == 1) {
                    if (log.isDebugEnabled()) {
                        log.debug("Case A: Not unmarshalling components, and only 1 block");
                    }
                    // Normal case: Only one body block
                    // We can use the get body block method
                    // that streams the whole block content.
                    Block block = message.getBodyBlock(context, factory);
                    //We look for body block only when the return type associated with operation is not void.
                    //If a null body block is returned in response on a operation that is not void, its a user error.              
                    returnElement = new Element(block.getBusinessObject(true), block.getQName());
                } else if (numBodyBlocks > 1) {
                    if (log.isDebugEnabled()) {
                        log.debug("Case B: Not unmarshalling components, and multiple blocks");
                    }
                    // There is only one return element
                    Block block = message.getBodyBlock(0, context, factory);
                    returnElement = new Element(block.getBusinessObject(true), block.getQName());

                }      
            } else {       
                if (numBodyBlocks > 0) {
                    if (log.isDebugEnabled()) {
                        log.debug("Case C: unmarshalling components.  Number of blocks=" + numBodyBlocks);
                    }
                    // Assume that all the qnames matching the first QName are for the return
                    List<QName> qNames = message.getBodyBlockQNames();
                    int firstIndex = 0;
                    int lastIndex = 0;
                    QName returnQName = qNames.get(0);
                    if (log.isDebugEnabled()) {
                        log.debug(" returnQName =" + returnQName);
                    }
                    do {
                        lastIndex++;
                    } while (lastIndex < qNames.size() &&
                            returnQName.equals(qNames.get(lastIndex)));

                    // Multiple Elements for QName
                    int numElements = lastIndex - firstIndex;
                    if (log.isDebugEnabled()) {
                        log.debug(" number of return blocks=" + numElements);
                    }
                    Object container = makeContainer(javaTypeClass,
                            javaComponentTypeClass,
                            numElements);
                   
                    for (int blockI=firstIndex; blockI<lastIndex; blockI++) {
                        Block block = message.getBodyBlock(blockI, context, factory);
                        Object value = block.getBusinessObject(true);
                        if (value instanceof JAXBElement) {
                            value = ((JAXBElement) value).getValue();
                        }
                        if (log.isDebugEnabled()) {
                            log.debug(" get return Business object (" + JavaUtils.getObjectIdentity(value) +
View Full Code Here

TOP

Related Classes of org.apache.axis2.jaxws.message.Block

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.