use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.
the class SAAJFactoryTest method addAttachmentPart.
private AttachmentPart addAttachmentPart(SOAPMessage msg, String value) {
AttachmentPart att = msg.createAttachmentPart(value, "text/html");
att.addMimeHeader(CUSTOM_MIME_HEADER_NAME, CUSTOM_MIME_HEADER_VALUE);
att.addMimeHeader(CUSTOM_MIME_HEADER_NAME2, CUSTOM_MIME_HEADER_VALUE2);
msg.addAttachmentPart(att);
return att;
}
use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.
the class AttachmentHelper method getAttachment.
public AttachmentPart getAttachment(java.net.URI ref, Iterator iter) {
if (iter == null || ref == null) {
System.err.println("getAttachment: null Iterator for AttachmentPart");
return null;
}
while (iter.hasNext()) {
AttachmentPart tempAttachment = (AttachmentPart) iter.next();
if (ref.isOpaque() && ref.getScheme().equals("cid")) {
String refId = ref.getSchemeSpecificPart();
String cId = tempAttachment.getContentId();
if (cId.equals("<" + refId + ">") || cId.equals(refId)) {
return tempAttachment;
}
}
}
return null;
}
use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.
the class JAXBAttachment method writeTo.
@Override
public void writeTo(SOAPMessage saaj) throws SOAPException {
AttachmentPart part = saaj.createAttachmentPart();
part.setDataHandler(asDataHandler());
part.setContentId(contentId);
saaj.addAttachmentPart(part);
}
use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.
the class HelloLiteralTest method getSOAPMessage.
private SOAPMessage getSOAPMessage() throws Exception {
byte[] bytes = helloSM.getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
MessageFactory factory = MessageFactory.newInstance();
SOAPMessage message = factory.createMessage();
message.getSOAPPart().setContent(new StreamSource(bis));
AttachmentPart ap = message.createAttachmentPart(getImage("java.jpg"), "image/jpeg");
message.addAttachmentPart(ap);
message.saveChanges();
return message;
}
use of jakarta.xml.soap.AttachmentPart in project metro-jax-ws by eclipse-ee4j.
the class MyHandler method handleMessage.
public boolean handleMessage(SOAPMessageContext smc) {
if (!(Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY))
return true;
try {
SOAPMessage msg = smc.getMessage();
AttachmentPart part = msg.createAttachmentPart(getDataHandler());
part.setContentId("SOAPTestHandler@example.jaxws.sun.com");
msg.addAttachmentPart(part);
msg.saveChanges();
smc.setMessage(msg);
} catch (Exception e) {
throw new WebServiceException(e);
}
return true;
}
Aggregations