use of com.sun.xml.ws.api.message.Attachment 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 com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.
the class ServerSOAPHandlerTube method callHandlersOnResponse.
void callHandlersOnResponse(MessageUpdatableContext context, boolean handleFault) {
// 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 (Map.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 {
// SERVER-SIDE
processor.callHandlersResponse(HandlerProcessor.Direction.OUTBOUND, context, handleFault);
} catch (RuntimeException wse) {
// no rewrapping
throw wse;
}
}
use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.
the class SAAJFactory method addAttachmentsToSOAPMessage.
protected static void addAttachmentsToSOAPMessage(SOAPMessage msg, Message message) {
for (Attachment att : message.getAttachments()) {
AttachmentPart part = msg.createAttachmentPart();
part.setDataHandler(att.asDataHandler());
// Be safe and avoid double angle-brackets.
String cid = att.getContentId();
if (cid != null) {
if (cid.startsWith("<") && cid.endsWith(">"))
part.setContentId(cid);
else
part.setContentId('<' + cid + '>');
}
// by the DataHandler above.
if (att instanceof AttachmentEx) {
AttachmentEx ax = (AttachmentEx) att;
Iterator<AttachmentEx.MimeHeader> imh = ax.getMimeHeaders();
while (imh.hasNext()) {
AttachmentEx.MimeHeader ame = imh.next();
if ((!"Content-ID".equalsIgnoreCase(ame.getName())) && (!"Content-Type".equalsIgnoreCase(ame.getName())))
part.addMimeHeader(ame.getName(), ame.getValue());
}
}
msg.addAttachmentPart(part);
}
}
use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.
the class MimeAttachmentSet method get.
@Nullable
public Attachment get(String contentId) {
Attachment att;
/*
First try to get the Attachment from internal map, maybe this attachment
is added by the user.
*/
att = atts.get(contentId);
if (att != null)
return att;
try {
/*
Attachment is not found in the internal map, now do look in
the mpp, if found add to the internal Attachment map.
*/
att = mpp.getAttachmentPart(contentId);
if (att != null) {
atts.put(contentId, att);
}
} catch (IOException e) {
throw new WebServiceException(EncodingMessages.NO_SUCH_CONTENT_ID(contentId), e);
}
return att;
}
use of com.sun.xml.ws.api.message.Attachment in project metro-jax-ws by eclipse-ee4j.
the class AttachmentMarshallerImpl method addSwaRefAttachment.
@Override
public String addSwaRefAttachment(DataHandler data) {
String cid = encodeCid(null);
Attachment att = new DataHandlerAttachment(cid, data);
attachments.add(att);
cid = "cid:" + cid;
return cid;
}
Aggregations