Search in sources :

Example 1 with StreamReaderBufferProcessor

use of com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReference method parseEPRExtensions.

private void parseEPRExtensions() throws XMLStreamException {
    rootEprExtensions = new HashMap<>();
    StreamReaderBufferProcessor xsr = infoset.readAsXMLStreamReader();
    // parser should be either at the start element or the start document
    if (xsr.getEventType() == XMLStreamReader.START_DOCUMENT) {
        xsr.nextTag();
    }
    assert xsr.getEventType() == XMLStreamReader.START_ELEMENT;
    if (!xsr.getNamespaceURI().equals(version.nsUri)) {
        throw new WebServiceException(AddressingMessages.WRONG_ADDRESSING_VERSION(version.nsUri, xsr.getNamespaceURI()));
    }
    // since often EPR doesn't have extensions, create array lazily
    XMLStreamBuffer mark;
    String localName;
    String ns;
    while ((mark = xsr.nextTagAndMark()) != null) {
        localName = xsr.getLocalName();
        ns = xsr.getNamespaceURI();
        if (version.nsUri.equals(ns)) {
            // EPR extensions do not use the same namespace of the Addressing Version.
            // Not an extension -  SKIP
            XMLStreamReaderUtil.skipElement(xsr);
        } else {
            QName qn = new QName(ns, localName);
            rootEprExtensions.put(qn, new WSEPRExtension(mark, qn));
            XMLStreamReaderUtil.skipElement(xsr);
        }
    }
// hit to </EndpointReference> by now
}
Also used : WebServiceException(jakarta.xml.ws.WebServiceException) QName(javax.xml.namespace.QName) MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) StreamReaderBufferProcessor(com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor) WSEPRExtension(com.sun.xml.ws.addressing.WSEPRExtension)

Example 2 with StreamReaderBufferProcessor

use of com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReferenceTest method creaateSubtreeEPR.

/**
 * This creates {@link WSEndpointReference} that uses a fragment infoset.
 * We should really fix this in XMLStreamBuffer.
 */
private WSEndpointReference creaateSubtreeEPR() throws XMLStreamException {
    XMLStreamBuffer xsb = XMLStreamBuffer.createNewBufferFromXMLStreamReader(XMLInputFactory.newInstance().createXMLStreamReader(getClass().getClassLoader().getResourceAsStream("test-epr.xml")));
    StreamReaderBufferProcessor p = xsb.readAsXMLStreamReader();
    XMLStreamBuffer mark = p.nextTagAndMark();
    return new WSEndpointReference(mark, W3C);
}
Also used : WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) StreamReaderBufferProcessor(com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor)

Example 3 with StreamReaderBufferProcessor

use of com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReference method parse.

/**
 * Parses inside EPR and mark all reference parameters.
 */
private void parse() throws XMLStreamException {
    // TODO: validate the EPR structure.
    // check for non-existent Address, that sort of things.
    StreamReaderBufferProcessor xsr = infoset.readAsXMLStreamReader();
    // parser should be either at the start element or the start document
    if (xsr.getEventType() == XMLStreamReader.START_DOCUMENT) {
        xsr.nextTag();
    }
    assert xsr.getEventType() == XMLStreamReader.START_ELEMENT;
    String rootLocalName = xsr.getLocalName();
    if (!xsr.getNamespaceURI().equals(version.nsUri)) {
        throw new WebServiceException(AddressingMessages.WRONG_ADDRESSING_VERSION(version.nsUri, xsr.getNamespaceURI()));
    }
    this.rootElement = new QName(xsr.getNamespaceURI(), rootLocalName);
    // since often EPR doesn't have a reference parameter, create array lazily
    List<Header> marks = null;
    while (xsr.nextTag() == XMLStreamReader.START_ELEMENT) {
        String localName = xsr.getLocalName();
        if (version.isReferenceParameter(localName)) {
            XMLStreamBuffer mark;
            while ((mark = xsr.nextTagAndMark()) != null) {
                if (marks == null) {
                    marks = new ArrayList<>();
                }
                // TODO: need a different header for member submission version
                marks.add(version.createReferenceParameterHeader(mark, xsr.getNamespaceURI(), xsr.getLocalName()));
                XMLStreamReaderUtil.skipElement(xsr);
            }
        } else if (localName.equals("Address")) {
            if (address != null) {
                throw new InvalidAddressingHeaderException(new QName(version.nsUri, rootLocalName), AddressingVersion.fault_duplicateAddressInEpr);
            }
            address = xsr.getElementText().trim();
        } else {
            XMLStreamReaderUtil.skipElement(xsr);
        }
    }
    if (marks == null) {
        this.referenceParameters = EMPTY_ARRAY;
    } else {
        this.referenceParameters = marks.toArray(new Header[0]);
    }
    if (address == null) {
        throw new InvalidAddressingHeaderException(new QName(version.nsUri, rootLocalName), version.fault_missingAddressInEpr);
    }
}
Also used : InvalidAddressingHeaderException(com.sun.xml.ws.addressing.model.InvalidAddressingHeaderException) WebServiceException(jakarta.xml.ws.WebServiceException) Header(com.sun.xml.ws.api.message.Header) QName(javax.xml.namespace.QName) MutableXMLStreamBuffer(com.sun.xml.stream.buffer.MutableXMLStreamBuffer) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) StreamReaderBufferProcessor(com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor)

Example 4 with StreamReaderBufferProcessor

use of com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor in project metro-jax-ws by eclipse-ee4j.

the class WSEndpointReferenceTest method creaateSubtreeEPR.

/**
 * This creates {@link WSEndpointReference} that uses a fragment infoset.
 * We should really fix this in XMLStreamBuffer.
 */
private WSEndpointReference creaateSubtreeEPR() throws XMLStreamException {
    XMLStreamBuffer xsb = XMLStreamBuffer.createNewBufferFromXMLStreamReader(XMLInputFactory.newInstance().createXMLStreamReader(getClass().getResourceAsStream("test-epr.xml")));
    StreamReaderBufferProcessor p = xsb.readAsXMLStreamReader();
    XMLStreamBuffer mark = p.nextTagAndMark();
    return new WSEndpointReference(mark, W3C);
}
Also used : WSEndpointReference(com.sun.xml.ws.api.addressing.WSEndpointReference) XMLStreamBuffer(com.sun.xml.stream.buffer.XMLStreamBuffer) StreamReaderBufferProcessor(com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor)

Aggregations

XMLStreamBuffer (com.sun.xml.stream.buffer.XMLStreamBuffer)4 StreamReaderBufferProcessor (com.sun.xml.stream.buffer.stax.StreamReaderBufferProcessor)4 MutableXMLStreamBuffer (com.sun.xml.stream.buffer.MutableXMLStreamBuffer)2 WSEndpointReference (com.sun.xml.ws.api.addressing.WSEndpointReference)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 QName (javax.xml.namespace.QName)2 WSEPRExtension (com.sun.xml.ws.addressing.WSEPRExtension)1 InvalidAddressingHeaderException (com.sun.xml.ws.addressing.model.InvalidAddressingHeaderException)1 Header (com.sun.xml.ws.api.message.Header)1