Package org.apache.cxf.staxutils

Examples of org.apache.cxf.staxutils.StaxSource


        private String findName(List<Source> sources, int i) {
            Source source = sources.get(i);
            if (source instanceof DOMSource) {
                return ((Element)((DOMSource)source).getNode()).getLocalName();
            } else if (source instanceof StaxSource) {
                StaxSource s = (StaxSource)source;
                return s.getXMLStreamReader().getLocalName();
            } else if (source instanceof StAXSource) {
                StAXSource s = (StAXSource)source;
                XMLStreamReader r = s.getXMLStreamReader();
                if (r.getEventType() != XMLStreamReader.START_ELEMENT) {
                    try {
                        r.nextTag();
                    } catch (XMLStreamException e) {
                        //ignore
View Full Code Here


        private String findName(List<Source> sources, int i) {
            Source source = sources.get(i);
            if (source instanceof DOMSource) {
                return ((Element)((DOMSource)source).getNode()).getLocalName();
            } else if (source instanceof StaxSource) {
                StaxSource s = (StaxSource)source;
                return s.getXMLStreamReader().getLocalName();
            } else if (source instanceof StAXSource) {
                StAXSource s = (StAXSource)source;
                XMLStreamReader r = s.getXMLStreamReader();
                if (r.getEventType() != XMLStreamReader.START_ELEMENT) {
                    try {
                        r.nextTag();
                    } catch (XMLStreamException e) {
                        //ignore
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(getReader(is));
        } else if (StreamSource.class.isAssignableFrom(theSource)
                   || Source.class.isAssignableFrom(theSource)) {
            return new StreamSource(getRealStream(is));
        } else if (XMLSource.class.isAssignableFrom(theSource)) {
            return 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"));
           
            if (opName == null) {
                opName = isOneWay ? INVOKE_ONEWAY_QNAME : INVOKE_QNAME;
            } else {
                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<AbstractFeature> endpointFeatures
                    = ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
                List<AbstractFeature> allFeatures;
                if (client.getBus().getFeatures() != null) {
                    allFeatures = new ArrayList<AbstractFeature>(endpointFeatures.size()
                        + client.getBus().getFeatures().size());
                    allFeatures.addAll(endpointFeatures);
                    allFeatures.addAll(client.getBus().getFeatures());
                } else {
                    allFeatures = endpointFeatures;
                }
                for (AbstractFeature feature : allFeatures) {
                    if (feature instanceof WSAddressingFeature) {
                        findDispatchOp = true;
                    }
                }
            }
            Map<String, QName> payloadOPMap =
                createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
            if (findDispatchOp && !payloadOPMap.isEmpty()) {
                String payloadElementName = null;             
                if (obj instanceof javax.xml.transform.Source) {
                    try {
                        XMLStreamReader 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
                    }
                }
View Full Code Here

                input = StaxUtils.createXMLStreamReader(dom);
            }
            if (type != null) {
                if (SAXSource.class.isAssignableFrom(type)
                    || StaxSource.class.isAssignableFrom(type)) {
                    return new StaxSource(resetForStreaming(input));
                } else if (StreamSource.class.isAssignableFrom(type)) {
                    return new StreamSource(getInputStream(input));
                } else if (XMLStreamReader.class.isAssignableFrom(type)) {
                    return resetForStreaming(input);
                } else if (DataSource.class.isAssignableFrom(type)) {
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

        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);
                      
            if (opName == null) {
                opName = new QName(DISPATCH_NS,
                                   isOneWay ? INVOKE_ONEWAY_NAME : INVOKE_NAME);
            }
           
            //CXF-2836 : find the operation for the dispatched object
            boolean wsaEnabled = false;
            // the feature list to be searched is the endpoint and the bus's lists
            List<AbstractFeature> endpointFeatures
                = ((JaxWsClientEndpointImpl)client.getEndpoint()).getFeatures();
            List<AbstractFeature> allFeatures;
            if (client.getBus().getFeatures() != null) {
                allFeatures = new ArrayList<AbstractFeature>(endpointFeatures.size()
                    + client.getBus().getFeatures().size());
                allFeatures.addAll(endpointFeatures);
                allFeatures.addAll(client.getBus().getFeatures());
            } else {
                allFeatures = endpointFeatures;
            }
            for (AbstractFeature feature : allFeatures) {
                if (feature instanceof WSAddressingFeature) {
                    wsaEnabled = true;
                }
            }
            Map<String, QName> payloadOPMap =
                createPayloadEleOpNameMap(client.getEndpoint().getBinding().getBindingInfo());
            if (wsaEnabled && !payloadOPMap.isEmpty()) {
                String payloadElementName = null;             
                if (obj instanceof javax.xml.transform.Source) {
                    try {
                        XMLStreamReader 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
                    }
                }
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

    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

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.