Java 8 SOAPPart - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 SOAPPart class.

This code example shows how to use the following methods:getEnvelope
    public void testAddFault() { 
        try { 
            MessageFactory fact = MessageFactory.newInstance();
            SOAPMessage message = fact.createMessage();
            SOAPPart soapPart = message.getSOAPPart();
            SOAPEnvelope soapEnvelope = soapPart.getEnvelope();
            SOAPBody soapBody = soapEnvelope.getBody();
 
            QName qname = new QName("http://test.apache.org/", "Child1", "ch");
            String value = "MyFault";
            SOAPFault soapFault = soapBody.addFault(qname, value);
            message.saveChanges();
            assertNotNull(soapFault);
            assertTrue(soapFault instanceof SOAPFault);
        } catch (Exception e) {
            fail("Unexpected Exception : " + e);
        } 
    } 
 
    @Validated @Test
4
CodeRank
This code example shows how to use the following methods:getEnvelope
            try { 
                // If the SessionHeader is null, or the session id is null - do nothing. 
                if (sh != null && sh.getSessionId() != null) {
                    SOAPMessage message = smc.getMessage();
                    SOAPPart part = message.getSOAPPart();
                    SOAPEnvelope envelope = part.getEnvelope();
                    SOAPHeader header = envelope.getHeader();
                    if (header == null) header = envelope.addHeader();
                    SOAPHeaderElement sessionHeaderElement = header.addHeaderElement(sessionHeader);
                    SOAPElement sessionIdElement = sessionHeaderElement.addChildElement(sessionId);
                    sessionIdElement.addTextNode(sh.getSessionId());
                } 
 
            } catch (SOAPException e) {
                e.printStackTrace();
                return false; 
            } 
            return true; 
        } 
 
4
CodeRank
This code example shows how to use the following methods:getParentElement, getParentNode
    public void test_parentAccess1() throws Exception {
 
        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage m = mf.createMessage();
        SOAPPart sp = m.getSOAPPart();
        Node node = sp.getParentNode();
        assertTrue(node == null);
         
        SOAPElement e = sp.getParentElement();
        assertTrue(node == null);
    } 
     
    // TODO: check why this fails with Sun's SAAJ implementation 
    @Test
    public void testNodeTypes() throws Exception {
        MessageFactory fact = MessageFactory.newInstance();
        SOAPMessage message = fact.createMessage();
        SOAPPart soapPart = message.getSOAPPart();     
 
        assertTrue("first child", soapPart.getFirstChild() instanceof SOAPEnvelope);
4
CodeRank
This code example shows how to use the following methods:getEnvelope
This code example shows how to use the following methods:getEnvelope
This code example shows how to use the following methods:getEnvelope
 
    @Before 
    public void setUp() throws Exception {
        msg = MessageFactory.newInstance().createMessage();
        sp = msg.getSOAPPart();
        envelope = sp.getEnvelope();
        body = envelope.getBody();
        header = envelope.getHeader();
        headerEle = header.addHeaderElement(envelope.createName("foo", "f", "foo-URI"));
        headerEle.setActor("actor-URI");
    } 
 
    @Validated @Test
    public void testDetachNode() { 
        try { 
            headerEle.detachNode();
            Iterator iterator = header.examineHeaderElements("actor-URI");
            assertFalse("SOAPHeader element is not detached - unexpected", iterator.hasNext());
        } catch (Exception e) {
            fail("Exception: " + e);
4
CodeRank
This code example shows how to use the following methods:getEnvelope
This code example shows how to use the following methods:getEnvelope
This code example shows how to use the following methods:getEnvelope
        SOAPMessage msg = factory.createMessage();
        SOAPPart part = msg.getSOAPPart();
 
        Document doc = docBuilder.parse(is);
 
        W3CDOMStreamWriter writer = new W3CDOMStreamWriter(part.getEnvelope());
        XMLStreamReader reader = StaxUtils.createXMLStreamReader(new DOMSource(doc));
 
        StaxUtils.copy(reader, writer);
        assertTrue(StaxUtils.toString(writer.getDocument()).endsWith(RESULT));
 
    } 
     
    @Test
    public void testTopLevelText() throws Exception {
        ByteArrayInputStream is = new ByteArrayInputStream(
               "<t:Test xmlns:t=\"http://example.org/types\">gorilla</t:Test>" 
               .getBytes("utf-8"));
        Document doc = StaxUtils.read(is);
        Element e = doc.getDocumentElement();
4
CodeRank
This code example shows how to use the following methods:getEnvelope
 
    @Before 
    public void setUp() throws Exception {
        msg = MessageFactory.newInstance().createMessage();
        sp = msg.getSOAPPart();
        envelope = sp.getEnvelope();
        body = envelope.getBody();
        header = envelope.getHeader();
        headerEle = header.addHeaderElement(envelope.createName("foo", "f", "foo-URI"));
        headerEle.setActor("actor-URI");
    } 
 
 
    /* 
    * for soap version 1.1 
    */ 
    @Validated @Test
    public void testAddDetailEntry() throws Exception {
        //Add a SOAPFault object to the SOAPBody 
        SOAPFault sf = body.addFault();
4
CodeRank
See Code Examples for Java 8 SOAPPart Methods: