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
}
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);
}
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);
}
}
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);
}
Aggregations