use of javax.xml.soap.AttachmentPart in project quickstarts by jboss-switchyard.
the class SoapAttachmentClient method main.
public static void main(String[] args) throws Exception {
String port = System.getProperty("org.switchyard.component.soap.client.port", "8080");
SOAPMessage response = sendMessage("http://localhost:" + port + "/soap-attachment/ImageServiceService");
SOAPUtil.prettyPrint(response, System.out);
@SuppressWarnings("unchecked") Iterator<AttachmentPart> iterator = response.getAttachments();
AttachmentPart ap = iterator.next();
System.out.println("Response attachment: " + ap.getContentId() + " with content type " + ap.getContentType());
}
use of javax.xml.soap.AttachmentPart in project quickstarts by jboss-switchyard.
the class SoapAttachmentClient method sendMessage.
public static SOAPMessage sendMessage(String switchyard_web_service) throws Exception {
SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance();
SOAPConnection connection = conFactory.createConnection();
MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
SOAPMessage msg = msgFactory.createMessage();
SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage"));
bodyElement.addTextNode("cid:switchyard.png");
AttachmentPart ap = msg.createAttachmentPart();
URL imageUrl = Classes.getResource("switchyard.png");
ap.setDataHandler(new DataHandler(new URLDataSource(imageUrl)));
ap.setContentId("switchyard.png");
msg.addAttachmentPart(ap);
return connection.call(msg, new URL(switchyard_web_service));
}
use of javax.xml.soap.AttachmentPart in project jdk8u_jdk by JetBrains.
the class MailTest method addSoapAttachement.
void addSoapAttachement() {
try {
MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage message = messageFactory.createMessage();
AttachmentPart a = message.createAttachmentPart();
a.setContentType("binary/octet-stream");
message.addAttachmentPart(a);
} catch (SOAPException e) {
e.printStackTrace();
}
}
Aggregations