Package javax.xml.soap

Examples of javax.xml.soap.SOAPConnection


        super(name);
    }

    public void testStringAttachment() throws Exception {
        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = scFactory.createConnection();

        MessageFactory factory = MessageFactory.newInstance();
        SOAPMessage message = factory.createMessage();
        AttachmentPart attachment = message.createAttachmentPart();
        String stringContent = "Update address for Sunny Skies " +
View Full Code Here


        assertTrue(message.countAttachments()==0);
    }

    public void testMultipleAttachments() throws Exception {
        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
        SOAPConnection con = scFactory.createConnection();

        MessageFactory factory = MessageFactory.newInstance();
        SOAPMessage msg = factory.createMessage();
        java.net.URL url1 = new java.net.URL("http://slashdot.org/slashdot.xml");
        java.net.URL url2 = new java.net.URL("http://www.apache.org/LICENSE.txt");
View Full Code Here

@RunWith(SAAJTestRunner.class)
public class SOAPConnectionTest extends Assert {
    @Validated @Test
    public void testClose() {
        try {
            SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
            sCon.close();
        } catch (SOAPException e) {
            fail("Unexpected Exception " + e);
        }
    }
View Full Code Here

            soapConnectionFactory = SOAPConnectionFactory.newInstance();
        } catch (SOAPException e) {
            fail("Unexpected Exception " + e);
        }

        SOAPConnection sCon = null;
        try {
            sCon = soapConnectionFactory.createConnection();
            sCon.close();
        } catch (SOAPException e) {
            fail("Unexpected Exception " + e);
        }

        try {
            sCon.close();
            fail("Expected Exception did not occur");
        } catch (SOAPException e) {
            assertTrue(true);
        }
    }
View Full Code Here

            soapConnectionFactory = SOAPConnectionFactory.newInstance();
        } catch (SOAPException e) {
            fail("Unexpected Exception " + e);
        }

        SOAPConnection sCon = null;
        try {
            sCon = soapConnectionFactory.createConnection();
            sCon.close();
        } catch (SOAPException e) {
            fail("Unexpected Exception " + e);
        }

        try {
            sCon.call(null, new Object());
            fail("Expected Exception did not occur");
        } catch (SOAPException e) {
            assertTrue(true);
        }
    }
View Full Code Here

        };
        context.addHandler(handler);
        server.start();
        try {
            SOAPConnectionFactory sf = new SOAPConnectionFactoryImpl();
            SOAPConnection con = sf.createConnection();
            URL urlEndpoint = new URL("http", "localhost", listener.getPort(), "/test");
            SOAPMessage reply = con.get(urlEndpoint);
            SOAPElement bodyElement = (SOAPElement)reply.getSOAPBody().getChildElements().next();
            assertEquals("root", bodyElement.getLocalName());
        } finally {
            server.stop();
        }
View Full Code Here

        //Namespace prefix is empty
        body.addBodyElement(new QName("http://fakeNamespace2.org","echo"))
                      .addTextNode("This is some text");

        SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage response = sCon.call(request, getAddress());
        assertFalse(response.getAttachments().hasNext());
        assertEquals(0, response.countAttachments());

        String requestStr = printSOAPMessage(request);
        String responseStr = printSOAPMessage(response);
        assertTrue(responseStr.indexOf("echo") > -1);
        sCon.close();
    }
View Full Code Here

        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage request = mf.createMessage();

        createSimpleSOAPPart(request);

        SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage response = sCon.call(request, getAddress());
        assertFalse(response.getAttachments().hasNext());
        assertEquals(0, response.countAttachments());

        String requestStr = printSOAPMessage(request);
        String responseStr = printSOAPMessage(response);
        assertTrue(responseStr.indexOf("echo") != -1);
        sCon.close();
    }
View Full Code Here

        jpegAttach.addMimeHeader("Content-Transfer-Encoding", "binary");
        jpegAttach.setContentId("submitSampleImage@apache.org");
        jpegAttach.setContentType("image/jpg");
        request.addAttachmentPart(jpegAttach);

        SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage response = sCon.call(request, getAddress());

        assertEquals(2, response.countAttachments());

        Iterator attachIter = response.getAttachments();

        int i = 0;
        while (attachIter.hasNext()) {
            AttachmentPart attachment = (AttachmentPart)attachIter.next();
            final Object content = attachment.getDataHandler().getContent();
            if (content instanceof String) {
                assertEquals(sampleMessage, (String)content);
            } else if (content instanceof ByteArrayInputStream) {
                ByteArrayInputStream bais = (ByteArrayInputStream)content;
                byte[] b = new byte[15000];
                final int lengthRead = bais.read(b);
                FileOutputStream fos =
                        new FileOutputStream(new File(System.getProperty("basedir", ".") + "/" +
                                "target/test-resources/result" + (i++) + ".jpg"));
                fos.write(b, 0, lengthRead);
                fos.flush();
                fos.close();

                assertTrue(attachment.getContentType().equals("image/jpeg")
                        || attachment.getContentType().equals("text/plain"));
            }
        }

        sCon.close();

    }
View Full Code Here

       
        InputStream inputStream = TestUtils.getTestFile("soap-part-iso-8859-1.xml");
        SOAPMessage requestMessage = MessageFactory.newInstance().createMessage(mimeHeaders, inputStream);
       

        SOAPConnection sCon = SOAPConnectionFactory.newInstance().createConnection();
        SOAPMessage response = sCon.call(requestMessage, getAddress());
        assertFalse(response.getAttachments().hasNext());
        assertEquals(0, response.countAttachments());

        printSOAPMessage(requestMessage);
        String responseStr = printSOAPMessage(response);
        assertEquals("This is some text.Here are some special chars : \u00F6\u00C6\u00DA\u00AE\u00A4",
                     response.getSOAPBody().getElementsByTagName("something").item(0).getTextContent());
        assertTrue(responseStr.indexOf("echo") != -1);
        sCon.close();
    }   
View Full Code Here

TOP

Related Classes of javax.xml.soap.SOAPConnection

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.