use of com.sun.xml.stream.buffer.MutableXMLStreamBuffer in project metro-jax-ws by eclipse-ee4j.
the class StreamMessage method cacheHeaders.
private static XMLStreamBuffer cacheHeaders(XMLStreamReader reader, Map<String, String> namespaces, HeaderList headers, StreamHeaderDecoder headerDecoder) throws XMLStreamException {
MutableXMLStreamBuffer buffer = createXMLStreamBuffer();
StreamReaderBufferCreator creator = new StreamReaderBufferCreator();
creator.setXMLStreamBuffer(buffer);
// Reader is positioned at the first header block
while (reader.getEventType() == javax.xml.stream.XMLStreamConstants.START_ELEMENT) {
Map<String, String> headerBlockNamespaces = namespaces;
// Collect namespaces on SOAP header block
if (reader.getNamespaceCount() > 0) {
headerBlockNamespaces = new HashMap<>(namespaces);
for (int i = 0; i < reader.getNamespaceCount(); i++) {
headerBlockNamespaces.put(reader.getNamespacePrefix(i), reader.getNamespaceURI(i));
}
}
// Mark
XMLStreamBuffer mark = new XMLStreamBufferMark(headerBlockNamespaces, creator);
// Create Header
headers.add(headerDecoder.decodeHeader(reader, mark));
// Cache the header block
// After caching Reader will be positioned at next header block or
// the end of the </soap:header>
creator.createElementFragment(reader, false);
if (reader.getEventType() != XMLStreamConstants.START_ELEMENT && reader.getEventType() != XMLStreamConstants.END_ELEMENT) {
XMLStreamReaderUtil.nextElementContent(reader);
}
}
return buffer;
}
use of com.sun.xml.stream.buffer.MutableXMLStreamBuffer in project metro-jax-ws by eclipse-ee4j.
the class WSDLGenResolver method getAbstractWSDL.
/**
* Updates filename if the suggested filename need to be changed in
* wsdl:import. If the metadata already contains abstract wsdl(i.e. a WSDL
* which has the porttype), then the abstract wsdl shouldn't be generated
*
* return null if abstract WSDL need not be generated
* Result the abstract WSDL
*/
public Result getAbstractWSDL(Holder<String> filename) {
if (abstractWsdl != null) {
filename.value = abstractWsdl.getURL().toString();
// Don't generate abstract WSDL
return null;
}
URL url = createURL(filename.value);
MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
xsb.setSystemId(url.toExternalForm());
SDDocumentSource abstractWsdlSource = SDDocumentSource.create(url, xsb);
newDocs.add(abstractWsdlSource);
XMLStreamBufferResult r = new XMLStreamBufferResult(xsb);
r.setSystemId(filename.value);
return r;
}
use of com.sun.xml.stream.buffer.MutableXMLStreamBuffer in project metro-jax-ws by eclipse-ee4j.
the class JAXBHeader method readHeader.
public XMLStreamReader readHeader() throws XMLStreamException {
if (infoset == null) {
MutableXMLStreamBuffer buffer = new MutableXMLStreamBuffer();
writeTo(buffer.createFromXMLStreamWriter());
infoset = buffer;
}
return infoset.readAsXMLStreamReader();
}
use of com.sun.xml.stream.buffer.MutableXMLStreamBuffer in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method create.
public static Message create(BindingContext context, Object jaxbObject, SOAPVersion soapVersion, MessageHeaders headers, AttachmentSet attachments) {
if (!context.hasSwaRef()) {
return new JAXBMessage(context, jaxbObject, soapVersion, headers, attachments);
}
try {
MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
Marshaller m = context.createMarshaller();
AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachments);
m.setAttachmentMarshaller(am);
am.cleanup();
m.marshal(jaxbObject, xsb.createFromXMLStreamWriter());
// any way to reuse this XMLStreamBuffer in StreamMessage?
return new StreamMessage(headers, attachments, xsb.readAsXMLStreamReader(), soapVersion);
} catch (JAXBException | XMLStreamException e) {
throw new WebServiceException(e);
}
}
use of com.sun.xml.stream.buffer.MutableXMLStreamBuffer in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method create.
/**
* Creates a {@link Message} backed by a JAXB bean.
*
* @param bridge
* Specify the payload tag name and how {@code jaxbObject} is bound.
*/
public static Message create(XMLBridge bridge, Object jaxbObject, SOAPVersion soapVer) {
if (!bridge.context().hasSwaRef()) {
return new JAXBMessage(bridge, jaxbObject, soapVer);
}
try {
MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer();
AttachmentSetImpl attachments = new AttachmentSetImpl();
AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachments);
bridge.marshal(jaxbObject, xsb.createFromXMLStreamWriter(), am);
am.cleanup();
// any way to reuse this XMLStreamBuffer in StreamMessage?
return new StreamMessage(null, attachments, xsb.readAsXMLStreamReader(), soapVer);
} catch (JAXBException | XMLStreamException e) {
throw new WebServiceException(e);
}
}
Aggregations