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

This code example shows how to use the following methods:getChildElements, appendChild, getChildNodes, getOwnerDocument
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addChildElement, addHeaderElement
This code example shows how to use the following methods:setElementQName
            //Caught expected SOAPException 
        } 
 
        //Try and change element name of SOAPHeader (expect SOAPException) 
        try { 
            header.setElementQName(qname);
            fail("Did not throw expected SOAPException");
        } catch (SOAPException e) {
            //Caught expected SOAPException 
        } 
 
        //Try and change element name of SOAPBody (expect SOAPException) 
        try { 
            body.setElementQName(qname);
            fail("Did not throw expected SOAPException");
        } catch (SOAPException e) {
            //Caught expected SOAPException 
        } 
    } 
     
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getChildElements
 
    private SOAPHeaderElement getSecurityHeader(SOAPEnvelope envelope) throws SOAPException {
        if (envelope != null) {
            SOAPHeader header = envelope.getHeader();
            if (header != null) {
                Iterator<?> iter = header.getChildElements(WSSE_QNAME);
                if (iter.hasNext()) {
                    return (SOAPHeaderElement)iter.next();
                } 
                iter = header.getChildElements(WSSE_2_QNAME);
                if (iter.hasNext()) {
                    return (SOAPHeaderElement)iter.next();
                } 
                iter = header.getChildElements(WSSE_11_QNAME);
                if (iter.hasNext()) {
                    return (SOAPHeaderElement)iter.next();
                } 
            } 
        } 
        return null; 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:examineHeaderElements
 
    @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);
        } 
    } 
 
    @Validated @Test
    public void testParentElement() { 
        try { 
            headerEle.detachNode();
            SOAPElement parentElement = headerEle.getParentElement();
            assertNull("Parent is not null : " + parentElement, parentElement);
        } catch (Exception e) {
            fail("Exception: " + e);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addChildElement
			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);
    	timestamp.setAttribute("wsu:Id", Util.generateId("Timestamp"));
    	 
    	SOAPElement createdDate = timestamp.addChildElement("Created", "wsu");
    	 
    	Calendar createdTime = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
    	Date todayDate = createdTime.getTime(); 
    	todayDate.setTime(todayDate.getTime() - 3600000); // - less 1 hour - 3600000 in winter, 7200000 in summer
    	 
    	createdDate.addTextNode(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss'Z'").format(todayDate));
    	 
    	Date expireDate = (Date)todayDate.clone();
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addChildElement, getChildElements, hasChildNodes
            SOAPFactory soapFactory = SOAPFactory.newInstance();
            oMessageIdElem = soapFactory.createElement(MESSAGE_ID, "", WSA_NS);
            oMessageIdElem.setTextContent(messageId);
 
            if (oHeader != null) {
                oHeader.addChildElement(oMessageIdElem);
            } 
        } 
    } 
 
    /** 
     * Returns a header object with a particular local name and namespace. 
     * @param header The header object from the message 
     * @param name The local name of the element being searched for 
     * @param ns The namespace of the object being searched for 
     * @return The first instance that matches the localname and namespace or return null 
     */ 
    private SOAPElement getFirstChild(SOAPHeader header, String name, String ns) {
        SOAPElement result = null;
        if (header == null || !header.hasChildNodes()) {

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:detachNode
This code example shows how to use the following methods:addHeaderElement
        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 
        Detail d = sf.addDetail();
        QName name = new QName("http://www.wombat.org/trader",
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:addHeaderElement
        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
    public void testGetResultSOAPMessage() throws Exception{
    	SAAJResult sr = new SAAJResult(msg);
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 SOAPHeader Methods: