Search in sources :

Example 1 with XMLReaderComposite

use of com.sun.xml.ws.util.xml.XMLReaderComposite in project metro-jax-ws by eclipse-ee4j.

the class XMLReaderCompositeTest method testComposite.

// @Test
public void testComposite() throws Exception {
    XMLStreamReader r = r("<root xmlns='ns0' xmlns:p1='ns1' att1='11' xmlns:p2='ns2' xmlns:p3='ns3'/>");
    XMLStreamReader x = r("<p1:x xmlns:p2='ns2' xmlns:p1='ns1' att2='22' p2:att2='11'/>");
    XMLStreamReader a = r("<a xmlns='ns0' att1='11'/>");
    XMLStreamReader b = r("<p1:b xmlns='ns0' att1='11' xmlns:p3='ns3' xmlns:p1='ns1'/>");
    TagInfoset rTag = new TagInfoset(r);
    ElemInfo rElem = new ElemInfo(rTag, null);
    TagInfoset xTag = new TagInfoset(x);
    ElemInfo xElem = new ElemInfo(xTag, rElem);
    XMLStreamReader[] kids = { a, b };
    XMLReaderComposite xrc = new XMLReaderComposite(xElem, kids);
    assertTrue(xrc.isStartElement());
    assertEquals(new QName("ns1", "x"), xrc.getName());
    assertEquals(2, xrc.getAttributeCount());
    assertEquals(2, xrc.getNamespaceCount());
    assertEquals("ns0", xrc.getNamespaceURI(""));
    assertEquals("ns3", xrc.getNamespaceURI("p3"));
    xrc.next();
    assertTrue(xrc.isStartElement());
    assertEquals(new QName("ns0", "a"), xrc.getName());
    assertEquals(1, xrc.getAttributeCount());
    xrc.next();
    assertTrue(xrc.isEndElement());
    xrc.next();
    assertTrue(xrc.isStartElement());
    assertEquals(new QName("ns1", "b"), xrc.getName());
    assertEquals(1, xrc.getAttributeCount());
    xrc.next();
    assertTrue(xrc.isEndElement());
    xrc.next();
    assertTrue(xrc.isEndElement());
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) ElemInfo(com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo) QName(javax.xml.namespace.QName) TagInfoset(com.sun.xml.ws.encoding.TagInfoset) XMLReaderComposite(com.sun.xml.ws.util.xml.XMLReaderComposite)

Example 2 with XMLReaderComposite

use of com.sun.xml.ws.util.xml.XMLReaderComposite in project metro-jax-ws by eclipse-ee4j.

the class JAXBMessage method readToBodyStarTag.

public XMLStreamReader readToBodyStarTag() {
    int base = soapVersion.ordinal() * 3;
    this.envelopeTag = DEFAULT_TAGS.get(base);
    this.bodyTag = DEFAULT_TAGS.get(base + 2);
    List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
    ElemInfo envElem = new ElemInfo(envelopeTag, null);
    ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
    for (Header h : getHeaders().asList()) {
        try {
            hReaders.add(h.readHeader());
        } catch (XMLStreamException e) {
            throw new RuntimeException(e);
        }
    }
    XMLStreamReader soapHeader = null;
    if (hReaders.size() > 0) {
        headerTag = DEFAULT_TAGS.get(base + 1);
        ElemInfo hdrElem = new ElemInfo(headerTag, envElem);
        soapHeader = new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0]));
    }
    XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, new XMLStreamReader[] {});
    XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
    return new XMLReaderComposite(envElem, soapContent);
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) ElemInfo(com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo) Header(com.sun.xml.ws.api.message.Header) XMLStreamException(javax.xml.stream.XMLStreamException) XMLReaderComposite(com.sun.xml.ws.util.xml.XMLReaderComposite)

Example 3 with XMLReaderComposite

use of com.sun.xml.ws.util.xml.XMLReaderComposite in project metro-jax-ws by eclipse-ee4j.

the class JAXBMessage method readEnvelope.

public XMLStreamReader readEnvelope() {
    int base = soapVersion.ordinal() * 3;
    this.envelopeTag = DEFAULT_TAGS.get(base);
    this.bodyTag = DEFAULT_TAGS.get(base + 2);
    List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
    ElemInfo envElem = new ElemInfo(envelopeTag, null);
    ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
    for (Header h : getHeaders().asList()) {
        try {
            hReaders.add(h.readHeader());
        } catch (XMLStreamException e) {
            throw new RuntimeException(e);
        }
    }
    XMLStreamReader soapHeader = null;
    if (hReaders.size() > 0) {
        headerTag = DEFAULT_TAGS.get(base + 1);
        ElemInfo hdrElem = new ElemInfo(headerTag, envElem);
        soapHeader = new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0]));
    }
    try {
        XMLStreamReader payload = readPayload();
        XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, new XMLStreamReader[] { payload });
        XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
        return new XMLReaderComposite(envElem, soapContent);
    } catch (XMLStreamException e) {
        throw new RuntimeException(e);
    }
}
Also used : XMLStreamReader(javax.xml.stream.XMLStreamReader) ElemInfo(com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo) Header(com.sun.xml.ws.api.message.Header) XMLStreamException(javax.xml.stream.XMLStreamException) XMLReaderComposite(com.sun.xml.ws.util.xml.XMLReaderComposite)

Example 4 with XMLReaderComposite

use of com.sun.xml.ws.util.xml.XMLReaderComposite in project metro-jax-ws by eclipse-ee4j.

the class StreamMessage method readToBodyStarTag.

public XMLStreamReader readToBodyStarTag() {
    if (envelopeReader != null)
        readEnvelope(this);
    List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
    ElemInfo envElem = new ElemInfo(envelopeTag, null);
    ElemInfo hdrElem = (headerTag != null) ? new ElemInfo(headerTag, envElem) : null;
    ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
    for (Header h : getHeaders().asList()) {
        try {
            hReaders.add(h.readHeader());
        } catch (XMLStreamException e) {
            throw new RuntimeException(e);
        }
    }
    XMLStreamReader soapHeader = (hdrElem != null) ? new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0])) : null;
    XMLStreamReader[] payload = {};
    XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, payload);
    XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
    return new XMLReaderComposite(envElem, soapContent);
}
Also used : ElemInfo(com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo) Header(com.sun.xml.ws.api.message.Header) ArrayList(java.util.ArrayList) XMLReaderComposite(com.sun.xml.ws.util.xml.XMLReaderComposite)

Example 5 with XMLReaderComposite

use of com.sun.xml.ws.util.xml.XMLReaderComposite in project metro-jax-ws by eclipse-ee4j.

the class StreamMessage method readEnvelope.

public XMLStreamReader readEnvelope() {
    if (envelopeReader == null) {
        List<XMLStreamReader> hReaders = new java.util.ArrayList<>();
        ElemInfo envElem = new ElemInfo(envelopeTag, null);
        ElemInfo hdrElem = (headerTag != null) ? new ElemInfo(headerTag, envElem) : null;
        ElemInfo bdyElem = new ElemInfo(bodyTag, envElem);
        for (Header h : getHeaders().asList()) {
            try {
                hReaders.add(h.readHeader());
            } catch (XMLStreamException e) {
                throw new RuntimeException(e);
            }
        }
        XMLStreamReader soapHeader = (hdrElem != null) ? new XMLReaderComposite(hdrElem, hReaders.toArray(new XMLStreamReader[0])) : null;
        XMLStreamReader[] payload = { readPayload() };
        XMLStreamReader soapBody = new XMLReaderComposite(bdyElem, payload);
        XMLStreamReader[] soapContent = (soapHeader != null) ? new XMLStreamReader[] { soapHeader, soapBody } : new XMLStreamReader[] { soapBody };
        return new XMLReaderComposite(envElem, soapContent);
    }
    return envelopeReader;
}
Also used : ElemInfo(com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo) Header(com.sun.xml.ws.api.message.Header) ArrayList(java.util.ArrayList) XMLReaderComposite(com.sun.xml.ws.util.xml.XMLReaderComposite)

Aggregations

XMLReaderComposite (com.sun.xml.ws.util.xml.XMLReaderComposite)5 ElemInfo (com.sun.xml.ws.util.xml.XMLReaderComposite.ElemInfo)5 Header (com.sun.xml.ws.api.message.Header)4 XMLStreamReader (javax.xml.stream.XMLStreamReader)3 ArrayList (java.util.ArrayList)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 TagInfoset (com.sun.xml.ws.encoding.TagInfoset)1 QName (javax.xml.namespace.QName)1