Java 8 SOAPEnvelope - 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 SOAPEnvelope class.

This code example shows how to use the following methods:addNamespaceDeclaration, setEncodingStyle, getBody
 
        addAuthorization(message, userName, password);
 
        SOAPEnvelope soapEnvelope = createEnvelope(message.getSOAPPart());
 
        SOAPBody soapBody = soapEnvelope.getBody();
        marshal(clazz, soapBody);
 
        message.saveChanges();
        return message;
    } 
 
    /** 
     * Creates SOAP message to be send to the SOAP server 
     * 
     * @return the created SOAP message 
     * @throws SOAPException 
     *             if unable to create soap message 
     */ 
    private static SOAPMessage createMessage() throws SOAPException {

6
CodeRank
This code example shows how to use the following methods:createName, getBody
 
    public void soapRequestResponse(SOAPEnvelope req, SOAPEnvelope resp) throws SOAPException
    { 
        // Echo back 
        logger.debug("envelopeTest Called");
        SOAPBody body = resp.getBody();
        Name ns0 = resp.createName("TestNS0", "ns0", "http://example.com");
        Name ns1 = resp.createName("TestNS1", "ns1", "http://example.com");
        SOAPElement bodyElmnt = body.addBodyElement(ns0);
        SOAPElement el = bodyElmnt.addChildElement(ns1);
        el.addTextNode("TEST RESPONSE");
    } 
} 
6
CodeRank
This code example shows how to use the following methods:createName, getBody
                "xmlns:child='http://springframework.org/spring-ws/2'>" + 
                "<child:Child attribute='value'>Content</child:Child></Root>"; 
        Source source = new StringSource(content);
        Result result = new SAXResult(handler);
        transformer.transform(source, result);
        Name rootName = envelope.createName("Root", "", "http://springframework.org/spring-ws/1");
        Iterator<?> iterator = envelope.getBody().getChildElements(rootName);
        Assert.assertTrue("No child found", iterator.hasNext());
        SOAPBodyElement rootElement = (SOAPBodyElement) iterator.next();
        Name childName = envelope.createName("Child", "child", "http://springframework.org/spring-ws/2");
        iterator = rootElement.getChildElements(childName);
        Assert.assertTrue("No child found", iterator.hasNext());
        SOAPElement childElement = (SOAPElement) iterator.next();
        Assert.assertEquals("Invalid contents", "Content", childElement.getValue());
        Name attributeName = envelope.createName("attribute");
        Assert.assertEquals("Invalid attribute value", "value", childElement.getAttributeValue(attributeName));
    } 
} 
6
CodeRank
This code example shows how to use the following methods:createName, getBody, getHeader
    @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");
    } 
 
    /* 
    public void testGetResult() throws Exception{ 
        SAAJResult sr = new SAAJResult(); 
        Node node = sr.getResult(); 
        assertNotNull(node); 
    } 
    */ 
 
    @Validated @Test
5
CodeRank
This code example shows how to use the following methods:createName, getBody, getHeader
    @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();
        //Add a Detail object to the SOAPFault object 
5
CodeRank
This code example shows how to use the following methods:getLocalName, getNamespaceURI, getPrefix
     * 
     * @param env 
     * @return QName 
     */ 
    private static QName getQName(SOAPEnvelope env) {
        return new QName(env.getNamespaceURI(), env.getLocalName(), env.getPrefix());
    } 
 
    public boolean isElementData() { 
        return true; 
    } 
     
    public void close() { 
        return; // Nothing to close 
    } 
 
    public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException {
        byte[] bytes = getXMLBytes(encoding);
        return new ByteArrayInputStream(bytes);
    } 
5
CodeRank
This code example shows how to use the following methods:addHeader, getHeader, getPrefix
	} 
	 
	public void insertWSSEheader(SOAPEnvelope env) throws ExceptionSOAPHeader theHeader;
		if(env.getHeader() == null)
		{ 
			theHeader = env.addHeader();
		} 
		else 
		{ 
			theHeader = env.getHeader();
		} 
		 
		 
		 
    	SOAPElement security = theHeader.addChildElement("Security", "wsse", QualipsoHandlerHeader.HTTP_SCHEMA_WSS_WSSECURITY_XSD);
    	security.setAttribute(env.getPrefix()+":mustUnderstand", "1");
    	 
    	SOAPElement timestamp = security.addChildElement("Timestamp", "wsu",QualipsoHandlerHeader.HTTP_NS_WSS_XSD);

5
CodeRank
This code example shows how to use the following methods:createName, getBody, getHeader
    @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);
        } 
5
CodeRank
This code example shows how to use the following methods:addHeader, getHeader
                // 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; 
        } 
 
        @Override 
5
CodeRank
This code example shows how to use the following methods:getHeader
See Code Examples for Java 8 SOAPEnvelope Methods: