21 * questions. 22 */ 23 24 import javax.xml.soap.AttachmentPart; 25 import javax.xml.soap.MessageFactory; 26 import javax.xml.soap.Name; 27 import javax.xml.soap.SOAPEnvelope; 28 import javax.xml.soap.SOAPException; 29 import javax.xml.soap.SOAPMessage; 30 import javax.xml.transform.stream.StreamSource; 31 import java.io.ByteArrayInputStream; 32 import java.io.ByteArrayOutputStream; 33 import java.io.File; 34 import java.io.FileInputStream; 35 import java.io.FileOutputStream; 36 import java.io.IOException; 37 import java.util.Iterator; 38 39 /* 40 * @test 41 * @compile -addmods java.xml.ws XmlTest.java 42 * @run main/othervm -addmods java.xml.ws XmlTest 43 * @summary tests JAF DataHandler can be instantiated; test serialize and 44 * deserialize SOAP message containing xml attachment 45 */ 46 public class XmlTest { 47 48 public void test() throws Exception { 49 50 File file = new File("message.xml"); 51 file.deleteOnExit(); 52 53 MessageFactory mf = MessageFactory.newInstance(); 54 SOAPMessage msg = createMessage(mf); 55 56 // Save the soap message to file 57 try (FileOutputStream sentFile = new FileOutputStream(file)) { 58 msg.writeTo(sentFile); 59 } 60 61 // See if we get the image object back 62 try (FileInputStream fin = new FileInputStream(file)) { | 21 * questions. 22 */ 23 24 import javax.xml.soap.AttachmentPart; 25 import javax.xml.soap.MessageFactory; 26 import javax.xml.soap.Name; 27 import javax.xml.soap.SOAPEnvelope; 28 import javax.xml.soap.SOAPException; 29 import javax.xml.soap.SOAPMessage; 30 import javax.xml.transform.stream.StreamSource; 31 import java.io.ByteArrayInputStream; 32 import java.io.ByteArrayOutputStream; 33 import java.io.File; 34 import java.io.FileInputStream; 35 import java.io.FileOutputStream; 36 import java.io.IOException; 37 import java.util.Iterator; 38 39 /* 40 * @test 41 * @modules java.xml.ws 42 * @run main XmlTest 43 * @summary tests JAF DataHandler can be instantiated; test serialize and 44 * deserialize SOAP message containing xml attachment 45 */ 46 public class XmlTest { 47 48 public void test() throws Exception { 49 50 File file = new File("message.xml"); 51 file.deleteOnExit(); 52 53 MessageFactory mf = MessageFactory.newInstance(); 54 SOAPMessage msg = createMessage(mf); 55 56 // Save the soap message to file 57 try (FileOutputStream sentFile = new FileOutputStream(file)) { 58 msg.writeTo(sentFile); 59 } 60 61 // See if we get the image object back 62 try (FileInputStream fin = new FileInputStream(file)) { |