Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPEnvelope


    public TestBodyHeaderOrder(OMMetaFactory metaFactory, SOAPSpec spec) {
        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope env = soapFactory.createSOAPEnvelope();
        soapFactory.createSOAPBody(env);
        soapFactory.createSOAPHeader(env);
        assertTrue("Header isn't the first child!", env.getFirstElement() instanceof SOAPHeader);
    }
View Full Code Here


    public TestHasFault(OMMetaFactory metaFactory, SOAPSpec spec) {
        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = soapFactory.createSOAPEnvelope();
        assertFalse(envelope.hasFault());
        SOAPBody body = soapFactory.createSOAPBody(envelope);
        assertFalse(envelope.hasFault());
        body.addFault(new Exception("This an exception for testing"));
        assertTrue(envelope.hasFault());
    }
View Full Code Here

    public TestGetBodyWithParser(OMMetaFactory metaFactory, SOAPSpec spec) {
        super(metaFactory, spec);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope envelope = getTestMessage(MESSAGE);
        SOAPBody body = envelope.getBody();
        assertEquals("Body Test : - Body local name mismatch",
                SOAPConstants.BODY_LOCAL_NAME, body.getLocalName());
        assertEquals("Body Test : - Body namespace mismatch",
                spec.getEnvelopeNamespaceURI(), body.getNamespace().getNamespaceURI());
    }
View Full Code Here

    }

    public void submitPurchaseOrderTest()
            throws Exception {
        SOAPFactory omFactory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = omFactory.getDefaultEnvelope();
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(
                omFactory, new InputStreamReader(
                                new ByteArrayInputStream(xmlText2.getBytes())));
        env.getBody().addChild(builder.getDocumentElement());

        // not sure why this test was created. Just checking whether serialization has worked or not. Someone
        // wanna check the correct thing later?
        String outputString = env.toString();
        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
    }
View Full Code Here

        String faultDetail = "org.apache.axis2.AxisFault: / by zero \n" +
                             "... 24 more)";
       
        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
       
        SOAPEnvelope envelope = factory.getDefaultFaultEnvelope();
        SOAPFault fault = envelope.getBody().getFault();
       
        fault.getCode().setText(faultCode);
       
        fault.getReason().setText(faultReason);
       
        OMElement exception = factory.createOMElement("Exception", null);
        exception.setText(faultDetail);
       
        fault.getDetail().addDetailEntry(exception);
       
        envelope.build();
       
        SOAPModelBuilder stAXSOAPModelBuilder = OMXMLBuilderFactory.createStAXSOAPModelBuilder(
                OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM),
                envelope.getXMLStreamReader());
        SOAPEnvelope env = stAXSOAPModelBuilder.getSOAPEnvelope();
        env.getParent().build();
       
        fault = env.getBody().getFault();
       
        assertEquals(faultCode, fault.getCode().getText());
        assertEquals(faultReason,fault.getReason().getText());
       
        exception = (OMElement)fault.getDetail().getFirstOMChild();
View Full Code Here

    public void testSerilizationWithCacheOn() throws Exception {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream,
                OMConstants.DEFAULT_CHAR_SET_ENCODING);

        SOAPEnvelope env = (SOAPEnvelope) builderOne.getDocumentElement();
        env.serialize(writer);
        writer.flush();
        assertTrue(new String(byteArrayOutputStream.toByteArray()).length() > 1);
    }
View Full Code Here

    /** Will just do a probe test to check serialize with caching off works without any exception */
    public void testSerilizationWithCacheOff() throws Exception {
        writer = StAXUtils.createXMLStreamWriter(new ByteArrayOutputStream(),
                OMConstants.DEFAULT_CHAR_SET_ENCODING);

        SOAPEnvelope env = (SOAPEnvelope) builderOne.getDocumentElement();
        env.serializeAndConsume(writer);
        writer.flush();
    }
View Full Code Here

                TestConstants.SOAP_SOAPMESSAGE), null);
        tempFile = File.createTempFile("temp", "xml");
    }

    public void testStaxBuilder() throws Exception {
        SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();
        assertNotNull(envelope);
        envelope.serialize(new FileOutputStream(tempFile));


    }
View Full Code Here

        this.file = file;
        addTestProperty("file", file);
    }

    protected void runTest() throws Throwable {
        SOAPEnvelope soapEnvelope = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory,
                AbstractTestCase.getTestResource(file), null).getSOAPEnvelope();
        OMTestUtils.walkThrough(soapEnvelope);
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document expected;
        InputStream in = AbstractTestCase.getTestResource(file);
        try {
            expected = db.parse(in);
        } finally {
            in.close();
        }
        Document actual = db.newDocument();
        // TODO: need to use getSAXSource (instead of toString) because of AXIOM-430
        TransformerFactory.newInstance().newTransformer().transform(soapEnvelope.getSAXSource(true), new DOMResult(actual));
        XMLAssert.assertXMLIdentical(XMLUnit.compareXML(expected, actual), true);
        soapEnvelope.close(false);
    }
View Full Code Here

    }

    public void testElementPullStream1() throws Exception {
        OMXMLParserWrapper builder = OMXMLBuilderFactory.createSOAPModelBuilder(
                getTestResource(TestConstants.SOAP_SOAPMESSAGE), null);
        SOAPEnvelope env = (SOAPEnvelope) builder.getDocumentElement();
        StreamingOMSerializer serializer = new StreamingOMSerializer();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        writer = StAXUtils.createXMLStreamWriter(byteArrayOutputStream);

        serializer.serialize(env.getXMLStreamReaderWithoutCaching(), writer);
        writer.flush();

        String outputString = new String(byteArrayOutputStream.toByteArray());
        assertTrue(outputString != null && !"".equals(outputString) && outputString.length() > 1);
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.soap.SOAPEnvelope

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.