Package org.apache.cxf.staxutils

Examples of org.apache.cxf.staxutils.StaxSource


    protected Object unmarshalFromReader(Unmarshaller unmarshaller, XMLStreamReader reader, MediaType mt)
        throws JAXBException {
        CachedOutputStream out = new CachedOutputStream();
        try {
            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
            StaxUtils.copy(new StaxSource(reader), writer);
            writer.writeEndDocument();
            writer.flush();
            writer.close();
            return unmarshalFromInputStream(unmarshaller, out.getInputStream(), mt);
        } catch (Exception ex) {
View Full Code Here


                    //ignore
                }
            }
        } else if (SAXSource.class.isAssignableFrom(theSource)
                  || StaxSource.class.isAssignableFrom(theSource)) {
            return source.cast(new StaxSource(getReader(is)));
        } else if (StreamSource.class.isAssignableFrom(theSource)
                   || Source.class.isAssignableFrom(theSource)) {
            return source.cast(new StreamSource(getRealStream(is)));
        } else if (XMLSource.class.isAssignableFrom(theSource)) {
            return source.cast(new XMLSource(getRealStream(is)));
View Full Code Here

        return new WebServiceException(ex);
    }
   
    @SuppressWarnings("unchecked")
    public T invoke(T obj, boolean isOneWay) {
        StaxSource createdSource = null;
        checkError();       
        try {
            if (obj instanceof SOAPMessage) {
                SOAPMessage msg = (SOAPMessage)obj;
                if (msg.countAttachments() > 0) {
                    client.getRequestContext().put(AttachmentOutInterceptor.WRITE_ATTACHMENTS, Boolean.TRUE);
                }
            } else if (context != null) {
                Boolean unwrapProperty = obj instanceof JAXBElement ? Boolean.FALSE : Boolean.TRUE;
                getRequestContext().put("unwrap.jaxb.element", unwrapProperty);
            }
            QName opName = (QName)getRequestContext().get(MessageContext.WSDL_OPERATION);
            boolean findDispatchOp = Boolean.TRUE.equals(getRequestContext().get("find.dispatch.operation"));
           
            boolean hasOpName;
            if (opName == null) {
                hasOpName = false;
                opName = isOneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME;
            } else {
                hasOpName = true;
                BindingOperationInfo bop = client.getEndpoint().getBinding()
                                            .getBindingInfo().getOperation(opName);
                if (bop == null) {
                    addInvokeOperation(opName, isOneWay);
                }
            }
           
            //CXF-2836 : find the operation for the dispatched object
            // if findDispatchOp is already true, skip the addressing feature lookup.
            // if the addressing feature is enabled, set findDispatchOp to true
            if (!findDispatchOp) {
                // the feature list to be searched is the endpoint and the bus's lists
                List<Feature> endpointFeatures
                    = ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
                List<Feature> allFeatures;
                if (client.getBus().getFeatures() != null) {
                    allFeatures = new ArrayList<Feature>(endpointFeatures.size()
                        + client.getBus().getFeatures().size());
                    allFeatures.addAll(endpointFeatures);
                    allFeatures.addAll(client.getBus().getFeatures());
                } else {
                    allFeatures = endpointFeatures;
                }
                for (Feature feature : allFeatures) {
                    if (feature instanceof WSAddressingFeature) {
                        findDispatchOp = true;
                    }
                }
            }
            Map<String, QName> payloadOPMap = createPayloadEleOpNameMap(
                    client.getEndpoint().getBinding().getBindingInfo(), hasOpName);
            if (findDispatchOp && !payloadOPMap.isEmpty()) {
                QName payloadElementName = null;
                if (obj instanceof javax.xml.transform.Source) {
                    XMLStreamReader reader = null;
                    try {
                        reader = StaxUtils.createXMLStreamReader((javax.xml.transform.Source)obj);
                        Document document = StaxUtils.read(reader);
                        createdSource = new StaxSource(StaxUtils.createXMLStreamReader(document));
                        payloadElementName = getPayloadElementName(document.getDocumentElement());
                    } catch (Exception e) {                       
                        // ignore, we are trying to get the operation name
                    } finally {
                        StaxUtils.close(reader);
View Full Code Here

                if (nd instanceof Document) {
                    nd = ((Document)nd).getDocumentElement();
                }
                return ((Element)nd).getLocalName();
            } else if (source instanceof StaxSource) {
                StaxSource s = (StaxSource)source;
                r = s.getXMLStreamReader();
            } else if (source instanceof StAXSource) {
                StAXSource s = (StAXSource)source;
                r = s.getXMLStreamReader();
            } else if (source instanceof StreamSource) {
                //flip to stax so we can get the name
                r = StaxUtils.createXMLStreamReader(source);
                StaxSource src2 = new StaxSource(r);
                sources.set(i, src2);
            }
            if (r != null) {
                try {
                    if (r.getEventType() == XMLStreamReader.START_DOCUMENT) {
View Full Code Here

                if (nd instanceof Document) {
                    nd = ((Document)nd).getDocumentElement();
                }
                return ((Element)nd).getLocalName();
            } else if (source instanceof StaxSource) {
                StaxSource s = (StaxSource)source;
                r = s.getXMLStreamReader();
            } else if (source instanceof StAXSource) {
                StAXSource s = (StAXSource)source;
                r = s.getXMLStreamReader();
            } else if (source instanceof StreamSource || source instanceof SAXSource) {
                //flip to stax so we can get the name
                r = StaxUtils.createXMLStreamReader(source);
                StaxSource src2 = new StaxSource(r);
                sources.set(i, src2);
            }
            if (r != null) {
                try {
                    if (r.getEventType() == XMLStreamConstants.START_DOCUMENT) {
View Full Code Here

            }
           
            if (unmarshaller.getClass().getName().contains("eclipse")) {
                //eclipse MOXy doesn't work properly with the XMLFilter/Reader thing
                //so we need to bounce through a DOM
                Source reader = new StaxSource(StaxUtils.createXMLStreamReader(is));
                DOMResult dom = new DOMResult();
                t.newTransformer().transform(reader, dom);
                return unmarshaller.unmarshal(dom.getNode());
            }
            XMLFilter filter = null;
            try {
                filter = factory.newXMLFilter(t);
            } catch (TransformerConfigurationException ex) {
                TemplatesImpl ti = (TemplatesImpl)t;
                filter = factory.newXMLFilter(ti.getTemplates());
                trySettingProperties(filter, ti);
            }
            XMLReader reader = new StaxSource(StaxUtils.createXMLStreamReader(is));
            filter.setParent(reader);
            SAXSource source = new SAXSource();
            source.setXMLReader(filter);
            if (systemId != null) {
                source.setSystemId(systemId);
View Full Code Here

                                         Annotation[] anns, MediaType mt)
        throws JAXBException {
        CachedOutputStream out = new CachedOutputStream();
        try {
            XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(out);
            StaxUtils.copy(new StaxSource(reader), writer);
            writer.writeEndDocument();
            writer.flush();
            writer.close();
            return unmarshalFromInputStream(unmarshaller, out.getInputStream(), anns, mt);
        } catch (Exception ex) {
View Full Code Here

            }
            if (type != null) {
                Object retVal = null;
                if (SAXSource.class.isAssignableFrom(type)
                    || StaxSource.class.isAssignableFrom(type)) {
                    retVal = new StaxSource(resetForStreaming(input));
                } else if (StreamSource.class.isAssignableFrom(type)) {
                    retVal = new StreamSource(getInputStream(input));
                } else if (XMLStreamReader.class.isAssignableFrom(type)) {
                    retVal = resetForStreaming(input);
                } else if (Element.class.isAssignableFrom(type)) {
View Full Code Here

                    //ignore
                }
            }
        } else if (SAXSource.class.isAssignableFrom(theSource)
                  || StaxSource.class.isAssignableFrom(theSource)) {
            return new StaxSource(StaxUtils.createXMLStreamReader(is));
        } else if (StreamSource.class.isAssignableFrom(theSource)
                   || Source.class.isAssignableFrom(theSource)) {
            return new StreamSource(is);
        } else if (XMLSource.class.isAssignableFrom(theSource)) {
            return new XMLSource(is);
View Full Code Here

            if (doneStax) {
                XMLReader reader = XMLReaderFactory.createXMLReader();
                return new SAXSource(reader, new InputSource(greetMeInputStream));
            } else {
                doneStax = true;
                return new StaxSource(StaxUtils.createXMLStreamReader(greetMeInputStream));
            }
        } else if (StreamSource.class.equals(class1)) {
            StreamSource source = new StreamSource();
            source.setInputStream(greetMeInputStream);
            return source;
View Full Code Here

TOP

Related Classes of org.apache.cxf.staxutils.StaxSource

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.