FileDocCategorySizeDatePackage
TestImport.javaAPI DocApache Axis 1.42808Sat Apr 22 18:57:28 BST 2006test.saaj

TestImport

public class TestImport extends test.AxisTestBase

Fields Summary
private static final String
SAMPLE_1
Constructors Summary
public TestImport(String name)

        super(name);
    
Methods Summary
private javax.xml.soap.SOAPMessagegetSOAPMessageFromString(java.lang.String str)


          
        MimeHeaders mimeHeaders = new MimeHeaders();
        mimeHeaders.addHeader("content-type", "text/xml");
        SOAPMessage message = MessageFactory.newInstance().createMessage(
                mimeHeaders,
                new ByteArrayInputStream(str.getBytes()));
        return message;
    
private org.w3c.dom.DocumenttestImportFromDomToSaaj(org.w3c.dom.Document doc)

        SOAPMessage sm = MessageFactory.newInstance().createMessage();
        SOAPPart sp = sm.getSOAPPart();
        SOAPBody body = sm.getSOAPBody();
        org.w3c.dom.Node node = sp.importNode(doc.getDocumentElement(), true);
        body.appendChild(node);
        return sp;
    
private org.w3c.dom.DocumenttestImportFromSaajToDom()

        SOAPMessage message = getSOAPMessageFromString(SAMPLE_1);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.newDocument();
        org.w3c.dom.Node fromNode = message.getSOAPBody().getFirstChild();
        Node n = doc.importNode(fromNode, true);
        doc.appendChild(n);
        return doc;
    
public voidtestImports()

        //DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        //DocumentBuilder db = dbf.newDocumentBuilder();
        //Document doc1 = db.parse(new ByteArrayInputStream(SAMPLE_1.getBytes()));

        Document doc2 = testImportFromSaajToDom();
        Document body = testImportFromDomToSaaj(doc2);
        XMLUtils.PrettyDocumentToStream(body, System.out);
        //assertXMLEqual(doc1, body);
        //assertXMLEqual(doc2, body);
        //assertXMLEqual(doc1, doc2);