use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class ClientMessageHandlerTube method callHandlersOnRequest.
boolean callHandlersOnRequest(MessageUpdatableContext context, boolean isOneWay) {
boolean handlerResult;
// Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
AttachmentSet attSet = context.packet.getMessage().getAttachments();
for (Entry<String, DataHandler> entry : atts.entrySet()) {
String cid = entry.getKey();
if (attSet.get(cid) == null) {
// Otherwise we would be adding attachments twice
Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
attSet.add(att);
}
}
try {
// CLIENT-SIDE
handlerResult = processor.callHandlersRequest(HandlerProcessor.Direction.OUTBOUND, context, !isOneWay);
} catch (WebServiceException wse) {
remedyActionTaken = true;
// no rewrapping
throw wse;
} catch (RuntimeException re) {
remedyActionTaken = true;
throw new WebServiceException(re);
}
if (!handlerResult) {
remedyActionTaken = true;
}
return handlerResult;
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class ClientSOAPHandlerTube method callHandlersOnRequest.
boolean callHandlersOnRequest(MessageUpdatableContext context, boolean isOneWay) {
boolean handlerResult;
// Lets copy all the MessageContext.OUTBOUND_ATTACHMENT_PROPERTY to the message
Map<String, DataHandler> atts = (Map<String, DataHandler>) context.get(MessageContext.OUTBOUND_MESSAGE_ATTACHMENTS);
AttachmentSet attSet = context.packet.getMessage().getAttachments();
for (Entry<String, DataHandler> entry : atts.entrySet()) {
String cid = entry.getKey();
if (attSet.get(cid) == null) {
// Otherwise we would be adding attachments twice
Attachment att = new DataHandlerAttachment(cid, atts.get(cid));
attSet.add(att);
}
}
try {
// CLIENT-SIDE
handlerResult = processor.callHandlersRequest(HandlerProcessor.Direction.OUTBOUND, context, !isOneWay);
} catch (WebServiceException wse) {
remedyActionTaken = true;
// no rewrapping
throw wse;
} catch (RuntimeException re) {
remedyActionTaken = true;
throw new WebServiceException(re);
}
if (!handlerResult) {
remedyActionTaken = true;
}
return handlerResult;
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method writePayloadTo.
/**
* Writes the payload as SAX events.
*/
@Override
protected void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException {
try {
if (fragment)
contentHandler = new FragmentContentHandler(contentHandler);
AttachmentMarshallerImpl am = new AttachmentMarshallerImpl(attachmentSet);
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.TRUE);
m.setAttachmentMarshaller(am);
m.marshal(jaxbObject, contentHandler);
} else
bridge.marshal(jaxbObject, contentHandler, am);
am.cleanup();
} catch (JAXBException e) {
// bug 6449684, spec 4.3.4
throw new WebServiceException(e.getMessage(), e);
}
}
use of jakarta.xml.ws.WebServiceException in project metro-jax-ws by eclipse-ee4j.
the class JAXBMessage method writePayloadTo.
@Override
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException {
try {
// MtomCodec sets its own AttachmentMarshaller
AttachmentMarshaller am = (sw instanceof MtomStreamWriter) ? ((MtomStreamWriter) sw).getAttachmentMarshaller() : new AttachmentMarshallerImpl(attachmentSet);
// Get the encoding of the writer
String encoding = XMLStreamWriterUtil.getEncoding(sw);
// Get output stream and use JAXB UTF-8 writer
OutputStream os = bridge.supportOutputStream() ? XMLStreamWriterUtil.getOutputStream(sw) : null;
if (rawContext != null) {
Marshaller m = rawContext.createMarshaller();
m.setProperty("jaxb.fragment", Boolean.TRUE);
m.setAttachmentMarshaller(am);
if (os != null) {
m.marshal(jaxbObject, os);
} else {
m.marshal(jaxbObject, sw);
}
} else {
if (os != null && encoding != null && encoding.equalsIgnoreCase(SOAPBindingCodec.UTF8_ENCODING)) {
bridge.marshal(jaxbObject, os, sw.getNamespaceContext(), am);
} else {
bridge.marshal(jaxbObject, sw, am);
}
}
// cleanup() is not needed since JAXB doesn't keep ref to AttachmentMarshaller
// am.cleanup();
} catch (JAXBException e) {
// bug 6449684, spec 4.3.4
throw new WebServiceException(e);
}
}
use of jakarta.xml.ws.WebServiceException 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);
}
}
Aggregations